falcon-40b / README.md
Daniel Hesslow
Update README.md
5887b76
|
raw
history blame
671 Bytes
# Example usage
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
import torch
model = "tiiuae/falcon-40B"
tokenizer = AutoTokenizer.from_pretrained(model)
pipeline = transformers.pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
torch_dtype=torch.bfloat16,
trust_remote_code=True,
device_map="auto",
)
sequences = pipeline(
"My favourite dad joke is",
max_length=200,
do_sample=True,
top_k=10,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
)
print("=" * 30)
print("Results:")
for seq in sequences:
print(f"Result: {seq['generated_text']}")
```