Instructions to use QuantFactory/selfrag_llama2_7b-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use QuantFactory/selfrag_llama2_7b-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use QuantFactory/selfrag_llama2_7b-GGUF with Ollama:
ollama run hf.co/QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M
- Unsloth Studio
How to use QuantFactory/selfrag_llama2_7b-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/selfrag_llama2_7b-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/selfrag_llama2_7b-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/selfrag_llama2_7b-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/selfrag_llama2_7b-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/selfrag_llama2_7b-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/selfrag_llama2_7b-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.selfrag_llama2_7b-GGUF-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
|
| 4 |
+
license: mit
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
[](https://hf.co/QuantFactory)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# QuantFactory/selfrag_llama2_7b-GGUF
|
| 12 |
+
This is quantized version of [selfrag/selfrag_llama2_7b](https://huggingface.co/selfrag/selfrag_llama2_7b) created using llama.cpp
|
| 13 |
+
|
| 14 |
+
# Original Model Card
|
| 15 |
+
|
| 16 |
+
This model is a 7B [Self-RAG](https://selfrag.github.io/) model that generates outputs to diverse user queries as well as *reflection tokens* to call the retrieval system adaptively and criticize its own output and retrieved passages.
|
| 17 |
+
|
| 18 |
+
Self-RAG is trained on our instruction-following corpora with interleaving passages and reflection tokens using the standard next-token prediction objective, enabling efficient and stable learning with fine-grained feedback.
|
| 19 |
+
At inference, we leverage reflection tokens covering diverse aspects of generations to sample the best output aligning users' preferences.
|
| 20 |
+
See full descriptions in See full descriptions in [our paper](https://arxiv.org/abs/2310.11511).
|
| 21 |
+
|
| 22 |
+
## Usage
|
| 23 |
+
Here, we show an easy way to quickly download our model from HuggingFace and run with `vllm` with pre-given passages. Make sure to install dependencies listed at [self-rag/requirements.txt](https://github.com/AkariAsai/self-rag/blob/main/requirements.txt).
|
| 24 |
+
To run our full inference pipeline with a retrieval system and fine-grained tree decoding, please use [our code](https://github.com/AkariAsai/self-rag).
|
| 25 |
+
|
| 26 |
+
```py
|
| 27 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 28 |
+
from vllm import LLM, SamplingParams
|
| 29 |
+
|
| 30 |
+
model = LLM("selfrag/selfrag_llama2_7b", download_dir="/gscratch/h2lab/akari/model_cache", dtype="half")
|
| 31 |
+
sampling_params = SamplingParams(temperature=0.0, top_p=1.0, max_tokens=100, skip_special_tokens=False)
|
| 32 |
+
|
| 33 |
+
def format_prompt(input, paragraph=None):
|
| 34 |
+
prompt = "### Instruction:\n{0}\n\n### Response:\n".format(input)
|
| 35 |
+
if paragraph is not None:
|
| 36 |
+
prompt += "[Retrieval]<paragraph>{0}</paragraph>".format(paragraph)
|
| 37 |
+
return prompt
|
| 38 |
+
|
| 39 |
+
query_1 = "Leave odd one out: twitter, instagram, whatsapp."
|
| 40 |
+
query_2 = "Can you tell me the difference between llamas and alpacas?"
|
| 41 |
+
queries = [query_1, query_2]
|
| 42 |
+
|
| 43 |
+
preds = model.generate([format_prompt(query) for query in queries], sampling_params)
|
| 44 |
+
for pred in preds:
|
| 45 |
+
print("Model prediction: {0}".format(pred.outputs[0].text))
|
| 46 |
+
# Model prediction: Twitter, Instagram, and WhatsApp are all social media platforms.[No Retrieval]WhatsApp is the odd one out because it is a messaging app, while Twitter and # Instagram are primarily used for sharing photos and videos.[Utility:5]</s> (this query doesn't require factual grounding; just skip retrieval and do normal instruction-following generation)
|
| 47 |
+
# Model prediction: Sure![Retrieval]<paragraph> ... (this query requires factual grounding, call a retriever)
|
| 48 |
+
|
| 49 |
+
# generate with retrieved passage
|
| 50 |
+
prompt = format_prompt("Can you tell me the difference between llamas and alpacas?", paragraph="The alpaca (Lama pacos) is a species of South American camelid mammal. It is similar to, and often confused with, the llama. Alpacas are considerably smaller than llamas, and unlike llamas, they were not bred to be working animals, but were bred specifically for their fiber.")
|
| 51 |
+
preds = model.generate([prompt], sampling_params)
|
| 52 |
+
print([pred.outputs[0].text for pred in preds])
|
| 53 |
+
# ['[Relevant]Alpacas are considerably smaller than llamas, and unlike llamas, they were not bred to be working animals, but were bred specifically for their fiber.[Fully supported][Utility:5]</s>']
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Input Format
|
| 57 |
+
As described in the `format_prompt` function, your input should be formed as
|
| 58 |
+
```
|
| 59 |
+
### Instruction:\n{instruction}\n\n### Response:\n".format(instruction)
|
| 60 |
+
```
|
| 61 |
+
or
|
| 62 |
+
```
|
| 63 |
+
### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
|
| 64 |
+
```
|
| 65 |
+
If you have additional input.
|
| 66 |
+
You can insert paragraphs anywhere after `### Response:\n"`, but make sure to mark paragraphs as paragraph tokens (i.e., `<paragraph>{0}</paragraph>`).
|
| 67 |
+
|
| 68 |
+
## Training details
|
| 69 |
+
Our training data is available at the HuggingFace dataset [selfrag_train_data](https://huggingface.co/datasets/selfrag/selfrag_train_data).
|
| 70 |
+
See our official repository for the training details.
|
| 71 |
+
We used 8 A100 40GB for training on the Stability HPC server.
|
| 72 |
+
|
| 73 |
+
## Citation and contact
|
| 74 |
+
If you use this model, please cite our work:
|
| 75 |
+
```
|
| 76 |
+
@article{asai2023selfrag,
|
| 77 |
+
author = {Asai, Akari and Wu, Zeqiu and Wang, Yizhong and Sil, Avirup and Hajishirzi, Hannaneh},
|
| 78 |
+
title = {{Self-RAG}: Learning to Retrieve, Generate, and Critique through Self-Reflection},
|
| 79 |
+
year = {2023},
|
| 80 |
+
journal = { arXiv preprint arXiv:2310.11511 },
|
| 81 |
+
URL = {https://arxiv.org/abs/2310.11511}
|
| 82 |
+
}
|
| 83 |
+
```
|