Instructions to use BabyChou/Yi-VL-34B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BabyChou/Yi-VL-34B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BabyChou/Yi-VL-34B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoProcessor, AutoModelForCausalLM processor = AutoProcessor.from_pretrained("BabyChou/Yi-VL-34B") model = AutoModelForCausalLM.from_pretrained("BabyChou/Yi-VL-34B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use BabyChou/Yi-VL-34B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BabyChou/Yi-VL-34B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BabyChou/Yi-VL-34B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/BabyChou/Yi-VL-34B
- SGLang
How to use BabyChou/Yi-VL-34B 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 "BabyChou/Yi-VL-34B" \ --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": "BabyChou/Yi-VL-34B", "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 "BabyChou/Yi-VL-34B" \ --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": "BabyChou/Yi-VL-34B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use BabyChou/Yi-VL-34B with Docker Model Runner:
docker model run hf.co/BabyChou/Yi-VL-34B
What is Yi-VL?
Architecture
Yi-VL adopts the LLaVA architecture, which is composed of three primary components:
Vision Transformer (ViT): it's initialized with CLIP ViT-H/14 model and used for image encoding.
Projection Module: it's designed to align image features with text feature space, consisting of a two-layer Multilayer Perceptron (MLP) with layer normalizations.
Large Language Model (LLM): it's initialized with Yi-34B-Chat or Yi-6B-Chat, demonstrating exceptional proficiency in understanding and generating both English and Chinese.
How to use Yi-VL?
Quick start
This has been implemented into the SGLang codebase, where you can simply call this model by creating a function like so:
import sglang as sgl
@sgl.function
def image_qa(s, image_path, question):
s += sgl.user(sgl.image(image_path) + question)
s += sgl.assistant(sgl.gen("answer"))
runtime = sgl.Runtime(model_path="BabyChou/Yi-VL-34B",
tokenizer_path="BabyChou/Yi-VL-34B")
sgl.set_default_backend(runtime)
# Single
state = image_qa.run(
image_path="images/cat.jpeg",
question="What is this?",
max_new_tokens=64)
print(state["answer"], "\n")
License
Please refer to the acknowledgments and attributions as well as individual components, for the license of source code.
The Yi series models are fully open for academic research and free for commercial use, permissions of which are automatically granted upon application.
All usage must adhere to the Yi Series Models Community License Agreement 2.1.
For free commercial use, you only need to send an email to get official commercial permission.
- Downloads last month
- 4
