Instructions to use GeneZC/MiniMA-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GeneZC/MiniMA-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="GeneZC/MiniMA-3B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniMA-3B") model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-3B") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use GeneZC/MiniMA-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "GeneZC/MiniMA-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GeneZC/MiniMA-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/GeneZC/MiniMA-3B
- SGLang
How to use GeneZC/MiniMA-3B 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 "GeneZC/MiniMA-3B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GeneZC/MiniMA-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "GeneZC/MiniMA-3B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GeneZC/MiniMA-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use GeneZC/MiniMA-3B with Docker Model Runner:
docker model run hf.co/GeneZC/MiniMA-3B
Update README.md
Browse files
README.md
CHANGED
|
@@ -10,4 +10,50 @@ language:
|
|
| 10 |
library_name: transformers
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
library_name: transformers
|
| 11 |
---
|
| 12 |
|
| 13 |
+
## MiniMA-3B
|
| 14 |
+
|
| 15 |
+
📑 [arXiv]() | 🤗 [HuggingFace](https://huggingface.co/GeneZC/MiniMA-3B) | 🤖 [ModelScope]()
|
| 16 |
+
|
| 17 |
+
A language model distilled from an adapted version of LLaMA2-7B following "Towards the Law of Capacity Gap in Distilling Language Models".
|
| 18 |
+
|
| 19 |
+
Establishing a new compute-performance pareto frontier.
|
| 20 |
+
|
| 21 |
+
<img src="./teaser_a.jpg" alt="teaser_a" width="400" />
|
| 22 |
+
|
| 23 |
+
The following is an example code snippet to use MiniMA-3B:
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
import torch
|
| 27 |
+
|
| 28 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 29 |
+
|
| 30 |
+
# MiniMA
|
| 31 |
+
tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniMA-3B", use_fast=False)
|
| 32 |
+
# GPU.
|
| 33 |
+
model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-3B", use_cache=True, device_map="auto", torch_dtype=torch.float16).eval()
|
| 34 |
+
# CPU.
|
| 35 |
+
# model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-3B", use_cache=True, device_map="cpu", torch_dtype=torch.float16).eval()
|
| 36 |
+
|
| 37 |
+
prompt = "Question: Sherrie tells the truth. Vernell says Sherrie tells the truth. Alexis says Vernell lies. Michaela says Alexis tells the truth. Elanor says Michaela tells the truth. Does Elanor tell the truth?\nAnswer: No\n\nQuestion: Kristian lies. Sherrie says Kristian lies. Delbert says Sherrie lies. Jerry says Delbert tells the truth. Shalonda says Jerry tells the truth. Does Shalonda tell the truth?\nAnswer: No\n\nQuestion: Vina tells the truth. Helene says Vina lies. Kandi says Helene tells the truth. Jamey says Kandi lies. Ka says Jamey lies. Does Ka tell the truth?\nAnswer: No\n\nQuestion: Christie tells the truth. Ka says Christie tells the truth. Delbert says Ka lies. Leda says Delbert tells the truth. Lorine says Leda tells the truth. Does Lorine tell the truth?\nAnswer:"
|
| 38 |
+
input_ids = tokenizer([prompt]).input_ids
|
| 39 |
+
output_ids = model.generate(
|
| 40 |
+
torch.as_tensor(input_ids).cuda(),
|
| 41 |
+
do_sample=True,
|
| 42 |
+
temperature=0.7,
|
| 43 |
+
max_new_tokens=1024,
|
| 44 |
+
)
|
| 45 |
+
output_ids = output_ids[0][len(input_ids[0]):]
|
| 46 |
+
output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
|
| 47 |
+
# output: "No"
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
## Bibtex
|
| 51 |
+
|
| 52 |
+
```bibtex
|
| 53 |
+
@article{zhang2023law,
|
| 54 |
+
title={Towards the Law of Capacity Gap in Distilling Language Models},
|
| 55 |
+
author={Zhang, Chen and Song, Dawei and Ye, Zheyu and Gao, Yan},
|
| 56 |
+
year={2023},
|
| 57 |
+
url={}
|
| 58 |
+
}
|
| 59 |
+
```
|