Text Generation
Transformers
PyTorch
Safetensors
English
idefics
image-text-to-text
multimodal
text
image
image-to-text
text-generation-inference
Instructions to use HuggingFaceM4/idefics-80b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceM4/idefics-80b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceM4/idefics-80b")# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics-80b") model = AutoModelForImageTextToText.from_pretrained("HuggingFaceM4/idefics-80b") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use HuggingFaceM4/idefics-80b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceM4/idefics-80b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceM4/idefics-80b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/HuggingFaceM4/idefics-80b
- SGLang
How to use HuggingFaceM4/idefics-80b 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 "HuggingFaceM4/idefics-80b" \ --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": "HuggingFaceM4/idefics-80b", "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 "HuggingFaceM4/idefics-80b" \ --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": "HuggingFaceM4/idefics-80b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use HuggingFaceM4/idefics-80b with Docker Model Runner:
docker model run hf.co/HuggingFaceM4/idefics-80b
Commit ·
8a29e64
1
Parent(s): 1552af8
update the generation args
Browse files
README.md
CHANGED
|
@@ -92,7 +92,10 @@ inputs = processor(prompts, return_tensors="pt").to(device)
|
|
| 92 |
# --single sample mode
|
| 93 |
# inputs = processor(prompts[0], return_tensors="pt").to(device)
|
| 94 |
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 97 |
for i, t in enumerate(generated_text):
|
| 98 |
print(f"{i}:\n{t}\n")
|
|
@@ -132,9 +135,12 @@ prompts = [
|
|
| 132 |
inputs = processor(prompts, add_end_of_utterance_token=False, return_tensors="pt").to(device)
|
| 133 |
# --single sample mode
|
| 134 |
# inputs = processor(prompts[0], return_tensors="pt").to(device)
|
|
|
|
|
|
|
| 135 |
exit_condition = processor.tokenizer("<end_of_utterance>", add_special_tokens=False).input_ids
|
|
|
|
| 136 |
|
| 137 |
-
generated_ids = model.generate(**inputs, eos_token_id=exit_condition, max_length=100)
|
| 138 |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 139 |
for i, t in enumerate(generated_text):
|
| 140 |
print(f"{i}:\n{t}\n")
|
|
|
|
| 92 |
# --single sample mode
|
| 93 |
# inputs = processor(prompts[0], return_tensors="pt").to(device)
|
| 94 |
|
| 95 |
+
# Generation args
|
| 96 |
+
bad_words_ids = tokenizer(["<image>", "<fake_token_around_image>"], add_special_tokens=False).input_ids
|
| 97 |
+
|
| 98 |
+
generated_ids = model.generate(**inputs, bad_words_ids=bad_words_ids, max_length=100)
|
| 99 |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 100 |
for i, t in enumerate(generated_text):
|
| 101 |
print(f"{i}:\n{t}\n")
|
|
|
|
| 135 |
inputs = processor(prompts, add_end_of_utterance_token=False, return_tensors="pt").to(device)
|
| 136 |
# --single sample mode
|
| 137 |
# inputs = processor(prompts[0], return_tensors="pt").to(device)
|
| 138 |
+
|
| 139 |
+
# Generation args
|
| 140 |
exit_condition = processor.tokenizer("<end_of_utterance>", add_special_tokens=False).input_ids
|
| 141 |
+
bad_words_ids = tokenizer(["<image>", "<fake_token_around_image>"], add_special_tokens=False).input_ids
|
| 142 |
|
| 143 |
+
generated_ids = model.generate(**inputs, eos_token_id=exit_condition, bad_words_ids=bad_words_ids, max_length=100)
|
| 144 |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 145 |
for i, t in enumerate(generated_text):
|
| 146 |
print(f"{i}:\n{t}\n")
|