Image-Text-to-Text
Transformers
Safetensors
English
phi
text-generation
medical
radiology
chest-x-ray
multimodal
report-generation
structured-reporting
contextualized
temporal-reasoning
impression
lora
medical-imaging
clinical-nlp
conversational
custom_code
text-generation-inference
Instructions to use erjui/CheXagent-2-3b-csrrg-impression with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use erjui/CheXagent-2-3b-csrrg-impression with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="erjui/CheXagent-2-3b-csrrg-impression", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("erjui/CheXagent-2-3b-csrrg-impression", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("erjui/CheXagent-2-3b-csrrg-impression", trust_remote_code=True, device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use erjui/CheXagent-2-3b-csrrg-impression with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "erjui/CheXagent-2-3b-csrrg-impression" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "erjui/CheXagent-2-3b-csrrg-impression", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/erjui/CheXagent-2-3b-csrrg-impression
- SGLang
How to use erjui/CheXagent-2-3b-csrrg-impression 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 "erjui/CheXagent-2-3b-csrrg-impression" \ --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": "erjui/CheXagent-2-3b-csrrg-impression", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "erjui/CheXagent-2-3b-csrrg-impression" \ --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": "erjui/CheXagent-2-3b-csrrg-impression", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use erjui/CheXagent-2-3b-csrrg-impression with Docker Model Runner:
docker model run hf.co/erjui/CheXagent-2-3b-csrrg-impression
| { | |
| "_name_or_path": "StanfordAIMI/CheXagent-2-3b", | |
| "architectures": [ | |
| "CheXagentForCausalLM" | |
| ], | |
| "attention_dropout": 0.0, | |
| "auto_map": { | |
| "AutoConfig": "StanfordAIMI/CheXagent-2-3b--configuration_chexagent.CheXagentConfig", | |
| "AutoModelForCausalLM": "StanfordAIMI/CheXagent-2-3b--modeling_chexagent.CheXagentForCausalLM" | |
| }, | |
| "bos_token_id": 50256, | |
| "embd_pdrop": 0.0, | |
| "eos_token_id": 50256, | |
| "hidden_act": "gelu_new", | |
| "hidden_size": 2560, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 10240, | |
| "layer_norm_eps": 1e-05, | |
| "max_position_embeddings": 2048, | |
| "model_type": "phi", | |
| "num_attention_heads": 32, | |
| "num_hidden_layers": 32, | |
| "num_key_value_heads": 32, | |
| "partial_rotary_factor": 0.4, | |
| "qk_layernorm": false, | |
| "resid_pdrop": 0.1, | |
| "rope_scaling": null, | |
| "rope_theta": 10000.0, | |
| "tie_word_embeddings": false, | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.40.0", | |
| "use_cache": false, | |
| "visual": { | |
| "image_size": 512, | |
| "output_dim": 2560, | |
| "vision_model_name_or_path": "StanfordAIMI/XraySigLIP__vit-l-16-siglip-384__webli" | |
| }, | |
| "vocab_size": 51200 | |
| } | |