Instructions to use NaughtyDog97/DiagramFormalizer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NaughtyDog97/DiagramFormalizer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NaughtyDog97/DiagramFormalizer", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("NaughtyDog97/DiagramFormalizer", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NaughtyDog97/DiagramFormalizer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NaughtyDog97/DiagramFormalizer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NaughtyDog97/DiagramFormalizer", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NaughtyDog97/DiagramFormalizer
- SGLang
How to use NaughtyDog97/DiagramFormalizer 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 "NaughtyDog97/DiagramFormalizer" \ --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": "NaughtyDog97/DiagramFormalizer", "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 "NaughtyDog97/DiagramFormalizer" \ --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": "NaughtyDog97/DiagramFormalizer", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NaughtyDog97/DiagramFormalizer with Docker Model Runner:
docker model run hf.co/NaughtyDog97/DiagramFormalizer
123
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ license: apache-2.0
|
|
| 4 |
# Diagram Formalizer
|
| 5 |
Model Structure:
|
| 6 |
|
| 7 |
-
<img src="sample/diagram_formalizer.png" alt="Alt text" width="
|
| 8 |
|
| 9 |
- **Diagram Encoder**: [siglip-so400m-patch14-384](https://huggingface.co/google/siglip-so400m-patch14-384)
|
| 10 |
|
|
@@ -47,7 +47,7 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
| 47 |
# text prompt
|
| 48 |
img_path = 'sample/4927.png'
|
| 49 |
prompt = 'Based on the image, first describe what you see in the figure, then predict the construction_cdl and image_cdl and calibrate it.'
|
| 50 |
-
text = f
|
| 51 |
|
| 52 |
def tokenizer_image_token(prompt, tokenizer, image_token_index, return_tensors=None):
|
| 53 |
prompt_chunks = [tokenizer(chunk).input_ids for chunk in prompt.split('<image>')]
|
|
|
|
| 4 |
# Diagram Formalizer
|
| 5 |
Model Structure:
|
| 6 |
|
| 7 |
+
<img src="sample/diagram_formalizer.png" alt="Alt text" width="50%" height="auto">
|
| 8 |
|
| 9 |
- **Diagram Encoder**: [siglip-so400m-patch14-384](https://huggingface.co/google/siglip-so400m-patch14-384)
|
| 10 |
|
|
|
|
| 47 |
# text prompt
|
| 48 |
img_path = 'sample/4927.png'
|
| 49 |
prompt = 'Based on the image, first describe what you see in the figure, then predict the construction_cdl and image_cdl and calibrate it.'
|
| 50 |
+
text = f'<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<image>\n{prompt}<|im_end|>\n<|im_start|>assistant\n'
|
| 51 |
|
| 52 |
def tokenizer_image_token(prompt, tokenizer, image_token_index, return_tensors=None):
|
| 53 |
prompt_chunks = [tokenizer(chunk).input_ids for chunk in prompt.split('<image>')]
|