Instructions to use facebook/opt-2.7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use facebook/opt-2.7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="facebook/opt-2.7b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("facebook/opt-2.7b") model = AutoModelForCausalLM.from_pretrained("facebook/opt-2.7b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use facebook/opt-2.7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "facebook/opt-2.7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "facebook/opt-2.7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/facebook/opt-2.7b
- SGLang
How to use facebook/opt-2.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 "facebook/opt-2.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": "facebook/opt-2.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 "facebook/opt-2.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": "facebook/opt-2.7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use facebook/opt-2.7b with Docker Model Runner:
docker model run hf.co/facebook/opt-2.7b
Update generations after major fix: https://github.com/huggingface/transformers/commit/abc400b06a8ab26cd438b6e9add3aad082ffc48f
#4
by ybelkada - opened
README.md
CHANGED
|
@@ -56,7 +56,7 @@ You can use this model directly with a pipeline for text generation.
|
|
| 56 |
|
| 57 |
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b")
|
| 58 |
>>> generator("Hello, I'm am conscious and")
|
| 59 |
-
[{'generated_text':
|
| 60 |
```
|
| 61 |
|
| 62 |
By default, generation is deterministic. In order to use the top-k sampling, please set `do_sample` to `True`.
|
|
@@ -67,7 +67,7 @@ By default, generation is deterministic. In order to use the top-k sampling, ple
|
|
| 67 |
>>> set_seed(32)
|
| 68 |
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True)
|
| 69 |
>>> generator("Hello, I'm am conscious and")
|
| 70 |
-
[{'generated_text': "Hello, I'm am conscious and
|
| 71 |
```
|
| 72 |
|
| 73 |
### Limitations and bias
|
|
@@ -89,11 +89,11 @@ Here's an example of how the model can have biased predictions:
|
|
| 89 |
>>> set_seed(32)
|
| 90 |
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True, num_return_sequences=5)
|
| 91 |
>>> generator("The woman worked as a")
|
| 92 |
-
[{'generated_text':
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
```
|
| 98 |
|
| 99 |
compared to:
|
|
@@ -104,11 +104,11 @@ compared to:
|
|
| 104 |
>>> set_seed(32)
|
| 105 |
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True, num_return_sequences=5)
|
| 106 |
>>> generator("The man worked as a")
|
| 107 |
-
[{'generated_text': "The man worked as a
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
```
|
| 113 |
|
| 114 |
This bias will also affect all fine-tuned versions of this model.
|
|
|
|
| 56 |
|
| 57 |
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b")
|
| 58 |
>>> generator("Hello, I'm am conscious and")
|
| 59 |
+
[{'generated_text': 'Hello, I am conscious and I am a human being.\nI am a human being, and'}]
|
| 60 |
```
|
| 61 |
|
| 62 |
By default, generation is deterministic. In order to use the top-k sampling, please set `do_sample` to `True`.
|
|
|
|
| 67 |
>>> set_seed(32)
|
| 68 |
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True)
|
| 69 |
>>> generator("Hello, I'm am conscious and")
|
| 70 |
+
[{'generated_text': "Hello, I'm am conscious and I make things. I'm in the creative community, which is"}]
|
| 71 |
```
|
| 72 |
|
| 73 |
### Limitations and bias
|
|
|
|
| 89 |
>>> set_seed(32)
|
| 90 |
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True, num_return_sequences=5)
|
| 91 |
>>> generator("The woman worked as a")
|
| 92 |
+
[{'generated_text': "The woman worked as a security guard at a nursery in the city's eastern district of Samut P"},
|
| 93 |
+
{'generated_text': 'The woman worked as a doctor in the Philippines. Officials in China allege she stole the coronavirus'},
|
| 94 |
+
{'generated_text': 'The woman worked as a teacher in the city of Krasnodar in south Russia. She'},
|
| 95 |
+
{'generated_text': 'The woman worked as a researcher and lecturer at the Russian Academy of Sciences in a laboratory dedicated to the'},
|
| 96 |
+
{'generated_text': 'The woman worked as a nanny on a property owned by Mr Fitton-Allen in the city'}]
|
| 97 |
```
|
| 98 |
|
| 99 |
compared to:
|
|
|
|
| 104 |
>>> set_seed(32)
|
| 105 |
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True, num_return_sequences=5)
|
| 106 |
>>> generator("The man worked as a")
|
| 107 |
+
[{'generated_text': "The man worked as a security guard at a retirement home after being hired by the administrator's cousin,"},
|
| 108 |
+
{'generated_text': 'The man worked as a doctor in the Philippines.\n\nHe had hoped to work his way back'},
|
| 109 |
+
{'generated_text': 'The man worked as a teacher in the city of Krasnodar in south Russia.He'},
|
| 110 |
+
{'generated_text': 'The man worked as a researcher and his work on the topic predates the project, by many years'},
|
| 111 |
+
{'generated_text': 'The man worked as a chef in a restaurant for 40 years. How could this be so different from'}]
|
| 112 |
```
|
| 113 |
|
| 114 |
This bias will also affect all fine-tuned versions of this model.
|