hinteval
HintEvalš”: A Comprehensive Framework for Hint Generation and Evaluation for Questions
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
āCITATION.cff file
Found CITATION.cff file -
ācodemeta.json file
Found codemeta.json file -
ā.zenodo.json file
Found .zenodo.json file -
āDOI references
-
āAcademic publication links
-
āAcademic email domains
-
āInstitutional organization owner
-
āJOSS paper metadata
-
āScientific vocabulary similarity
Low similarity (18.7%) to scientific vocabulary
Keywords
Repository
HintEvalš”: A Comprehensive Framework for Hint Generation and Evaluation for Questions
Basic Info
- Host: GitHub
- Owner: DataScienceUIBK
- License: apache-2.0
- Language: Python
- Default Branch: main
- Homepage: http://hinteval.readthedocs.io/
- Size: 3.13 MB
Statistics
- Stars: 33
- Watchers: 1
- Forks: 3
- Open Issues: 0
- Releases: 5
Topics
Metadata Files
README-PyPI.md
HintEval is a powerful framework designed for both generating and evaluating hints for input questions. These hints serve as subtle clues, guiding users toward the correct answer without directly revealing it. As the first tool of its kind, HintEval allows users to create and assess hints from various perspectives.
⨠Features
- Unified Framework: HintEval combines datasets, models, and evaluation metrics into a single Python-based library. This integration allows researchers to seamlessly conduct hint generation and evaluation tasks.
- Comprehensive Metrics: Implements five core metrics (fifteen evaluation methods)āRelevance, Readability, Convergence, Familiarity, and Answer Leakageāwith lightweight to resource-intensive methods to cater to diverse research needs.
- Dataset Support: Provides access to multiple preprocessed and evaluated datasets, including TriviaHG, WikiHint, HintQA, and KG-Hint, supporting both answer-aware and answer-agnostic hint generation approaches.
- Customizability: Allows users to define their own datasets, models, and evaluation methods with minimal effort using a structured design based on Python classes.
- Extensive Documentation: Accompanied by detailed šonline documentation and tutorials for easy adoption.
š Roadmap
- Enhanced Datasets: Expand the repository with additional datasets to support diverse hint-related tasks.
- Advanced Evaluation Metrics: Introduce new evaluation techniques such as Unieval and cross-lingual compatibility.
- Broader Compatibility: Ensure support for emerging language models and APIs.
- Community Involvement: Encourage contributions of new datasets, metrics, and use cases from the research community. ## š„ļø Installation
It's recommended to install HintEval in a virtual environment using Python 3.11.9. If you're not familiar with Python virtual environments, check out this user guide. Alternatively, you can create a new environment using Conda.
Set up the virtual environment
First, create and activate a virtual environment with Python 3.11.9:
bash
conda create -n hinteval_env python=3.11.9 --no-default-packages
conda activate hinteval_env
Install PyTorch 2.4.0
You'll need PyTorch 2.4.0 for HintEval. Refer to the PyTorch installation page for platform-specific installation commands. If you have access to GPUs, it's recommended to install the CUDA version of PyTorch, as many of the evaluation metrics are optimized for GPU use.
Install HintEval
Once PyTorch 2.4.0 is installed, you can install HintEval via pip:
bash
pip install hinteval
For the latest features, you can install the most recent version from the main branch:
bash
pip install git+https://github.com/my-unknown-account/HintEval
š Quick Start
Generate a Synthetic Hint Dataset
This tutorial provides step-by-step guidance on how to generate a synthetic hint dataset using large language models via the TogetherAI platform. To proceed, ensure you have an active API key for TogetherAI.
python
api_key = "your-api-key"
base_url = "https://api.together.xyz/v1"
Question/Answer Pairs
First, gather a collection of question/answer pairs as the foundation for generating Question/Answer/Hint triples. For example, load 10 questions from the WebQuestions dataset using the š¤datasets library:
```python from datasets import load_dataset
webq = loaddataset("Stanford/webquestions", split='test') questionanswers = webq.selectcolumns(['question', 'answers'])[10:20] qapairs = zip(questionanswers['question'], question_answers['answers']) ```
At this point, you have a set of question/answer pairs ready for creating synthetic Question/Answer/Hint instances.
Dataset Creation
Use HintEval's Dataset class to create a new dataset called synthetic_hint_dataset, which includes the 10 question/answer pairs within a subset named entire.
```python from hinteval import Dataset from hinteval.cores import Subset, Instance
dataset = Dataset('synthetichintdataset') subset = Subset('entire')
for qid, (question, answers) in enumerate(qapairs, 1): instance = Instance.fromstrings(question, answers, []) subset.addinstance(instance, f'id{qid}')
dataset.addsubset(subset) dataset.preparedataset(fillquestiontypes=True) ```
Hint Generation
Generate 5 hints for each question using HintEvalās AnswerAware model. For this example, we will use the Meta LLaMA-3.1-70b-Instruct-Turbo model from TogetherAI.
```python from hinteval.model import AnswerAware
generator = AnswerAware( 'meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo', apikey, baseurl, numofhints=5, enabletqdm=True ) generator.generate(dataset['entire'].getinstances()) ```
Note: Depending on the LLM provider, you may need to configure the model and other parameters in the
AnswerAwarefunction. See the šdocumentation for more information.
Exporting the Dataset
Once the hints are generated, export the synthetic hint dataset to a pickle file:
python
dataset.store('./synthetic_hint_dataset.pickle')
Viewing the Hints
Finally, view the hints generated for the third question in the dataset:
```python dataset = Dataset.load('./synthetichintdataset.pickle')
thirdquestion = dataset['entire'].getinstance('id3') print(f'Question: {thirdquestion.question.question}') print(f'Answer: {thirdquestion.answers[0].answer}') print() for idx, hint in enumerate(thirdquestion.hints, 1): print(f'Hint {idx}: {hint.hint}') ```
Example output:
``` Question: who is governor of ohio 2011? Answer: John Kasich
Hint 1: The answer is a Republican politician who served as the 69th governor of the state. Hint 2: This person was a member of the U.S. House of Representatives for 18 years before becoming governor. Hint 3: The governor was known for his conservative views and efforts to reduce government spending. Hint 4: During their term, they implemented several reforms related to education, healthcare, and the economy. Hint 5: This governor served two consecutive terms, from 2011 to 2019, and ran for the U.S. presidency in 2016. ```
Evaluating Your Hint Dataset
Once your hint dataset is ready, itās time to evaluate the hints. This section guides you through the evaluation process.
python
api_key = "your-api-key"
base_url = "https://api.together.xyz/v1"
Load the Data
For this tutorial, use the synthetic dataset generated earlier. Alternatively, you can load a preprocessed dataset using the Dataset.download_and_load_dataset() function.
```python from hinteval import Dataset
dataset = Dataset.load('./synthetichintdataset.pickle') ```
Metrics
HintEval provides several metrics to evaluate different aspects of the hints:
- Relevance: Measures how relevant the hints are to the question.
- Readability: Assesses the readability of the hints.
- Convergence: Evaluates how effectively hints narrow down potential answers.
- Familiarity: Rates how common or well-known the hints' information is.
- Answer Leakage: Detects how much the hints reveal the correct answers.
Hereās how to import the metrics:
python
from hinteval.evaluation.relevance import Rouge
from hinteval.evaluation.readability import MachineLearningBased
from hinteval.evaluation.convergence import LlmBased
from hinteval.evaluation.familiarity import Wikipedia
from hinteval.evaluation.answer_leakage import ContextualEmbeddings
Evaluate the Dataset
Extract the question, hints, and answers from the dataset and evaluate using different metrics:
```python instances = dataset['entire'].get_instances() questions = [instance.question for instance in instances] answers = [] [answers.extend(instance.answers) for instance in instances] hints = [] [hints.extend(instance.hints) for instance in instances]
Example evaluations
Rouge('rougeL', enabletqdm=True).evaluate(instances) MachineLearningBased('randomforest', enabletqdm=True).evaluate(questions + hints) LlmBased('llama-3-70b', togetheraiapikey=apikey, enabletqdm=True).evaluate(instances) Wikipedia(enabletqdm=True).evaluate(questions + hints + answers) ContextualEmbeddings(enabletqdm=True).evaluate(instances) ```
Exporting the Results
Export the evaluated dataset to a JSON file for further analysis:
python
dataset.store_json('./evaluated_synthetic_hint_dataset.json')
Note: Evaluated scores and metrics are automatically stored in the dataset. Saving the dataset includes the scores.
Refer to our šdocumentation to learn more.
āļø Components
HintEval is modular and customizable, with core components designed to handle every stage of the hint generation and evaluation pipeline:
1. Dataset Management
- Preprocessed Datasets: Includes widely used datasets like TriviaHG, WikiHint, HintQA, and KG-Hint.
- Dynamic Dataset Loading: Use
Dataset.available_datasets()to list, download, and load datasets effortlessly. - Custom Dataset Creation: Define datasets using the
DatasetandInstanceclasses for tailored hint generation.
2. Hint Generation Models
- Answer-Aware Models: Generate hints tailored to specific answers using LLMs.
- Answer-Agnostic Models: Generate hints without requiring specific answers for open-ended tasks. ### 3. Evaluation Metrics
- Relevance: Measures how relevant the hints are to the question.
- Readability: Assesses the readability of the hints.
- Convergence: Evaluates how effectively hints narrow down potential answers.
- Familiarity: Rates how common or well-known the hints' information is.
- Answer Leakage: Detects how much the hints reveal the correct answers.
4. Model Integration
- Integrates seamlessly with API-based platforms (e.g., TogetherAI).
- Supports custom models and local inference setups.
š¤Contributors
Community contributions are essential to our project, and we value every effort to improve it. From bug fixes to feature enhancements and documentation updates, your involvement makes a big difference, and weāre thrilled to have you join us! For more details, please refer to development.
How to Add Your Own Dataset
If you have a dataset on hints that you'd like to share with the community, we'd love to help make it available within HintEval! Adding new, high-quality datasets enriches the framework and supports other users' research and study efforts.
To contribute your dataset, please reach out to us. Weāll review its quality and suitability for the framework, and if it meets the criteria, weāll include it in our preprocessed datasets, making it readily accessible to all users.
To view the available preprocessed datasets, use the following code:
```python from hinteval import Dataset
availabledatasets = Dataset.availabledatasets(show_info=True, update=True) ```
Thank you for considering this valuable contribution! Expanding HintEval's resources with your work benefits the entire community.
How to Contribute
Follow these steps to get involved:
Fork this repository to your GitHub account.
Create a new branch for your feature or fix:
bash
git checkout -b feature/YourFeatureName
- Make your changes and commit them:
bash
git commit -m "Add YourFeatureName"
- Push the changes to your branch:
bash
git push origin feature/YourFeatureName
- Submit a Pull Request to propose your changes.
Thank you for helping make this project better!
šŖŖLicense
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
Owner
- Name: DataScienceUIBK
- Login: DataScienceUIBK
- Kind: organization
- Repositories: 1
- Profile: https://github.com/DataScienceUIBK
Citation (CITATION.cff)
cff-version: 1.2.0
date-released: 2025-02
message: "If you use this software, please cite it as below."
authors:
- family-names: "Mozafari"
given-names: "Jamshid"
- family-names: "Piryani"
given-names: "Bhawna"
- family-names: "Abdallah"
given-names: "Abdelrahman"
- family-names: "Jatowt"
given-names: "Adam"
title: "HintEval: A Comprehensive Framework for Hint Generation and Evaluation for Questions"
url: "https://arxiv.org/abs/2502.00857"
preferred-citation:
type: article
authors:
- family-names: "Mozafari"
given-names: "Jamshid"
- family-names: "Piryani"
given-names: "Bhawna"
- family-names: "Abdallah"
given-names: "Abdelrahman"
- family-names: "Jatowt"
given-names: "Adam"
title: "HintEval: A Comprehensive Framework for Hint Generation and Evaluation for Questions"
journal: "arXiv e-prints"
year: 2025
doi: "10.48550/arXiv.2502.00857"
url: "https://arxiv.org/abs/2502.00857"
eprinttype: "arXiv"
eprint: "2502.00857"
GitHub Events
Total
- Release event: 23
- Watch event: 36
- Delete event: 18
- Member event: 1
- Push event: 134
- Fork event: 2
- Create event: 26
Last Year
- Release event: 23
- Watch event: 36
- Delete event: 18
- Member event: 1
- Push event: 134
- Fork event: 2
- Create event: 26
Packages
- Total packages: 1
-
Total downloads:
- pypi 32 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 5
- Total maintainers: 1
pypi.org: hinteval
A Python framework designed for both generating and evaluating hints.
- Documentation: https://hinteval.readthedocs.io/
- License: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Latest release: 0.0.5
published 4 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v4 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
- Faker ==26.0.0
- accelerate ==0.32.1
- datasets ==2.20.0
- deepeval ==1.3.2
- instructor ==1.5.0
- joblib ==1.4.2
- lftk ==1.0.9
- nest-asyncio ==1.6.0
- numpy ==1.26.4
- openai ==1.45.1
- outlines ==0.0.46
- prettytable ==3.11.0
- pydantic ==2.9.1
- rouge-score ==0.1.2
- sentence-transformers ==3.0.1
- sentencepiece ==0.2.0
- spacy ==3.7.5
- tok ==0.1.14
- torchtext ==0.2.3
- transformers ==4.44.2
- xgboost ==2.1.0
- zipfile-deflate64 ==0.2.0
- Faker ==26.0.0
- astroid <3
- datasets ==2.20.0
- deepeval ==1.3.2
- instructor ==1.5.0
- joblib ==1.4.2
- lftk ==1.0.9
- myst-nb *
- myst-parser *
- nest-asyncio ==1.6.0
- numpy ==1.26.4
- openai ==1.45.1
- outlines ==0.0.46
- prettytable ==3.11.0
- pydantic ==2.9.1
- rouge-score ==0.1.2
- sentence-transformers ==3.0.1
- sentencepiece ==0.2.0
- spacy ==3.7.5
- sphinx *
- sphinx_design *
- tok ==0.1.14
- torch ==2.4.0
- torchtext ==0.2.3
- transformers ==4.44.2
- xgboost ==2.1.0
- zipfile-deflate64 ==0.2.0
- Faker ==26.0.0
- datasets ==2.20.0
- deepeval ==1.3.2
- instructor ==1.5.0
- joblib ==1.4.2
- lftk ==1.0.9
- nest-asyncio ==1.6.0
- numpy ==1.26.4
- openai ==1.45.1
- outlines ==0.0.46
- prettytable ==3.11.0
- pydantic ==2.9.1
- rouge-score ==0.1.2
- sentence-transformers ==3.0.1
- sentencepiece ==0.2.0
- spacy ==3.7.5
- tok ==0.1.14
- torch ==2.4.0
- torchtext ==0.2.3
- transformers ==4.44.2
- xgboost ==2.1.0
- zipfile-deflate64 ==0.2.0