Text Generation
Transformers
Safetensors
mistral
conversational
custom_code
text-generation-inference
Instructions to use GritLM/GritLM-7B-KTO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GritLM/GritLM-7B-KTO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="GritLM/GritLM-7B-KTO", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("GritLM/GritLM-7B-KTO", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("GritLM/GritLM-7B-KTO", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use GritLM/GritLM-7B-KTO with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "GritLM/GritLM-7B-KTO" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GritLM/GritLM-7B-KTO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/GritLM/GritLM-7B-KTO
- SGLang
How to use GritLM/GritLM-7B-KTO with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "GritLM/GritLM-7B-KTO" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GritLM/GritLM-7B-KTO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "GritLM/GritLM-7B-KTO" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GritLM/GritLM-7B-KTO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use GritLM/GritLM-7B-KTO with Docker Model Runner:
docker model run hf.co/GritLM/GritLM-7B-KTO
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: text-generation
|
| 3 |
+
inference: true
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
datasets:
|
| 6 |
+
- GritLM/tulu2
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Model Summary
|
| 11 |
+
|
| 12 |
+
A [**KTO**](https://arxiv.org/abs/2402.01306) version of https://huggingface.co/GritLM/GritLM-7B
|
| 13 |
+
|
| 14 |
+
> GritLM is a generative representational instruction tuned language model. It unifies text representation (embedding) and text generation into a single model achieving state-of-the-art performance on both types of tasks.
|
| 15 |
+
|
| 16 |
+
- **Repository:** [ContextualAI/gritlm](https://github.com/ContextualAI/gritlm)
|
| 17 |
+
- **Paper:** https://arxiv.org/abs/2402.09906
|
| 18 |
+
- **Logs:** https://wandb.ai/muennighoff/gritlm/runs/0uui712t/overview
|
| 19 |
+
- **Script:** https://github.com/ContextualAI/gritlm/blob/main/scripts/training/train_gritlm_7b.sh
|
| 20 |
+
|
| 21 |
+
| Model | Description |
|
| 22 |
+
|-------|-------------|
|
| 23 |
+
| [GritLM 7B](https://hf.co/GritLM/GritLM-7B) | Mistral 7B finetuned using GRIT |
|
| 24 |
+
| [GritLM 8x7B](https://hf.co/GritLM/GritLM-8x7B) | Mixtral 8x7B finetuned using GRIT |
|
| 25 |
+
|
| 26 |
+
# Use
|
| 27 |
+
|
| 28 |
+
The model usage is documented [here](https://github.com/ContextualAI/gritlm?tab=readme-ov-file#inference).
|
| 29 |
+
|
| 30 |
+
# Citation
|
| 31 |
+
|
| 32 |
+
```bibtex
|
| 33 |
+
@misc{muennighoff2024generative,
|
| 34 |
+
title={Generative Representational Instruction Tuning},
|
| 35 |
+
author={Niklas Muennighoff and Hongjin Su and Liang Wang and Nan Yang and Furu Wei and Tao Yu and Amanpreet Singh and Douwe Kiela},
|
| 36 |
+
year={2024},
|
| 37 |
+
eprint={2402.09906},
|
| 38 |
+
archivePrefix={arXiv},
|
| 39 |
+
primaryClass={cs.CL}
|
| 40 |
+
}
|
| 41 |
+
```
|