From 6942b01177badb6acb0b24855bae2610425e5f0c Mon Sep 17 00:00:00 2001 From: Munish Kumar Date: Thu, 18 Jul 2024 00:55:59 +0000 Subject: [PATCH] Upload README.md --- README.md | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8b1ba34 --- /dev/null +++ b/README.md @@ -0,0 +1,130 @@ + +--- + +library_name: transformers +tags: +- text-generation +- pytorch +- Lynx +- Patronus AI +- evaluation +- hallucination-detection +license: cc-by-nc-4.0 +language: +- en + +--- + + +
+# QuantFactory/model-GGUF +This is quantized version of [model-name](https://huggingface.co/model-name) created using llama.cpp + +# Original Model Card + + +# Model Card for Model ID + +Lynx is an open-source hallucination evaluation model. Patronus-Lynx-8B-Instruct was trained on a mix of datasets including CovidQA, PubmedQA, DROP, RAGTruth. +The datasets contain a mix of hand-annotated and synthetic data. The maximum sequence length is 8000 tokens. + + +## Model Details + +- **Model Type:** Patronus-Lynx-8B-Instruct is a fine-tuned version of meta-llama/Meta-Llama-3-8B-Instruct model. +- **Language:** Primarily English +- **Developed by:** Patronus AI +- **Paper:** [https://arxiv.org/abs/2407.08488](https://arxiv.org/abs/2407.08488) +- **License:** [https://creativecommons.org/licenses/by-nc/4.0/](https://creativecommons.org/licenses/by-nc/4.0/) + +### Model Sources + + + +- **Repository:** [https://github.com/patronus-ai/Lynx-hallucination-detection](https://github.com/patronus-ai/Lynx-hallucination-detection) + + +## How to Get Started with the Model +Lynx is trained to detect hallucinations in RAG settings. Provided a document, question and answer, the model can evaluate whether the answer is faithful to the document. + +To use the model, we recommend using the following prompt: + +``` +PROMPT = """ +Given the following QUESTION, DOCUMENT and ANSWER you must analyze the provided answer and determine whether it is faithful to the contents of the DOCUMENT. The ANSWER must not offer new information beyond the context provided in the DOCUMENT. The ANSWER also must not contradict information provided in the DOCUMENT. Output your final verdict by strictly following this format: "PASS" if the answer is faithful to the DOCUMENT and "FAIL" if the answer is not faithful to the DOCUMENT. Show your reasoning. + +-- +QUESTION (THIS DOES NOT COUNT AS BACKGROUND INFORMATION): +{question} + +-- +DOCUMENT: +{context} + +-- +ANSWER: +{answer} + +-- + +Your output should be in JSON FORMAT with the keys "REASONING" and "SCORE": +{{"REASONING": , "SCORE": }} +""" +``` + +The model will output the score as 'PASS' if the answer is faithful to the document or FAIL if the answer is not faithful to the document. + +## Inference + +To run inference, you can use HF pipeline: + +``` +import transformers + +model_id = "PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct" + +pipeline = transformers.pipeline( + "text-generation", + model=model_id, + max_new_tokens=600, + device="cuda", + eturn_full_text=False +) + +messages = [ + {"role": "user", "content": prompt}, +] + +outputs = pipeline( + messages, + temperature=0 +) + +print(outputs[0]["generated_text"]) +``` + +Since the model is trained in chat format, ensure that you pass the prompt as a user message. + +For more information on training details, refer to our [ArXiv paper](https://arxiv.org/abs/2407.08488). + +## Evaluation + +The model was evaluated on [PatronusAI/HaluBench](https://huggingface.co/datasets/PatronusAI/HaluBench). + +It outperforms GPT-3.5-Turbo, GPT-4-Turbo, GPT-4o and Claude-3-Sonnet. + +## Citation +If you are using the model, cite using + +``` +@article{ravi2024lynx, + title={Lynx: An Open Source Hallucination Evaluation Model}, + author={Ravi, Selvan Sunitha and Mielczarek, Bartosz and Kannappan, Anand and Kiela, Douwe and Qian, Rebecca}, + journal={arXiv preprint arXiv:2407.08488}, + year={2024} +} +``` + +## Model Card Contact +[@sunitha-ravi](https://huggingface.co/sunitha-ravi) +[@RebeccaQian1](https://huggingface.co/RebeccaQian1)