Instructions to use OpenMOSS-Team/moss-base-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenMOSS-Team/moss-base-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenMOSS-Team/moss-base-7b", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("OpenMOSS-Team/moss-base-7b", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenMOSS-Team/moss-base-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenMOSS-Team/moss-base-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenMOSS-Team/moss-base-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OpenMOSS-Team/moss-base-7b
- SGLang
How to use OpenMOSS-Team/moss-base-7b 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 "OpenMOSS-Team/moss-base-7b" \ --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": "OpenMOSS-Team/moss-base-7b", "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 "OpenMOSS-Team/moss-base-7b" \ --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": "OpenMOSS-Team/moss-base-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use OpenMOSS-Team/moss-base-7b with Docker Model Runner:
docker model run hf.co/OpenMOSS-Team/moss-base-7b
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Import from Transformers
|
| 2 |
+
To load the Moss 7B model using Transformers, use the following code:
|
| 3 |
+
```python
|
| 4 |
+
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("fnlp/moss-base-7b", trust_remote_code=True)
|
| 6 |
+
>>> model = AutoModelForCausalLM.from_pretrained("fnlp/moss-base-7b", trust_remote_code=True).cuda()
|
| 7 |
+
>>> model = model.eval()
|
| 8 |
+
>>> inputs = tokenizer(["流浪地球的导演是"], return_tensors="pt")
|
| 9 |
+
>>> for k,v in inputs.items():
|
| 10 |
+
inputs[k] = v.cuda()
|
| 11 |
+
>>> outputs = model.generate(**inputs, do_sample=True, temperature=0.8, top_p=0.8, repetition_penalty=1.1, max_new_tokens=256)
|
| 12 |
+
>>> response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 13 |
+
>>> print(response)
|
| 14 |
+
郭帆
|
| 15 |
+
主演分别是吴京和屈楚萧 还有李光洁刘德华等等
|
| 16 |
+
这电影可以说是目前国内科幻片的天花板了
|
| 17 |
+
票房也是突破50亿大关啦
|
| 18 |
+
小编真的非常期待这部电影呀
|
| 19 |
+
所以呢今天就给大家整理了关于影片中的很多细节图哦~
|
| 20 |
+
不知道大家有没有注意到呢
|