Instructions to use LCM-Lab/nsa_llama with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LCM-Lab/nsa_llama with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="LCM-Lab/nsa_llama") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("LCM-Lab/nsa_llama") model = AutoModelForCausalLM.from_pretrained("LCM-Lab/nsa_llama") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use LCM-Lab/nsa_llama with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LCM-Lab/nsa_llama" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LCM-Lab/nsa_llama", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/LCM-Lab/nsa_llama
- SGLang
How to use LCM-Lab/nsa_llama 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 "LCM-Lab/nsa_llama" \ --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": "LCM-Lab/nsa_llama", "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 "LCM-Lab/nsa_llama" \ --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": "LCM-Lab/nsa_llama", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use LCM-Lab/nsa_llama with Docker Model Runner:
docker model run hf.co/LCM-Lab/nsa_llama
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,48 +1,14 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
#language:
|
| 14 |
-
##语言代码列表 https://help.aliyun.com/document_detail/215387.html?spm=a2c4g.11186623.0.0.9f8d7467kni6Aa
|
| 15 |
-
#- cn
|
| 16 |
-
|
| 17 |
-
#metrics:
|
| 18 |
-
##如 CIDEr、Blue、ROUGE 等
|
| 19 |
-
#- CIDEr
|
| 20 |
-
|
| 21 |
-
#tags:
|
| 22 |
-
##各种自定义,包括 pretrained、fine-tuned、instruction-tuned、RL-tuned 等训练方法和其他
|
| 23 |
-
#- pretrained
|
| 24 |
-
|
| 25 |
-
#tools:
|
| 26 |
-
##如 vllm、fastchat、llamacpp、AdaSeq 等
|
| 27 |
-
#- vllm
|
| 28 |
---
|
| 29 |
-
|
| 30 |
-
#### 您可以通过如下git clone命令,或者ModelScope SDK来下载模型
|
| 31 |
-
|
| 32 |
-
SDK下载
|
| 33 |
-
```bash
|
| 34 |
-
#安装ModelScope
|
| 35 |
-
pip install modelscope
|
| 36 |
-
```
|
| 37 |
-
```python
|
| 38 |
-
#SDK模型下载
|
| 39 |
-
from modelscope import snapshot_download
|
| 40 |
-
model_dir = snapshot_download('younySheep/nsa_llama')
|
| 41 |
-
```
|
| 42 |
-
Git下载
|
| 43 |
-
```
|
| 44 |
-
#Git模型下载
|
| 45 |
-
git clone https://www.modelscope.cn/younySheep/nsa_llama.git
|
| 46 |
-
```
|
| 47 |
-
|
| 48 |
-
<p style="color: lightgrey;">如果您是本模型的贡献者,我们邀请您根据<a href="https://modelscope.cn/docs/ModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88" style="color: lightgrey; text-decoration: underline;">模型贡献文档</a>,及时完善模型卡片内容。</p>
|
|
|
|
| 1 |
---
|
| 2 |
+
frameworks:
|
| 3 |
+
- pytorch
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
tasks:
|
| 6 |
+
- text-generation
|
| 7 |
+
language:
|
| 8 |
+
- en
|
| 9 |
+
base_model:
|
| 10 |
+
- Llama/Llama-3.1-8B-Instruct
|
| 11 |
+
pipeline_tag: text-generation
|
| 12 |
+
library_name: transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
+
[Elastic Attention: Test-time Adaptive Sparsity Ratios for Efficient Transformers](https://www.arxiv.org/abs/2601.17367)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|