Image-Text-to-Text
Transformers
Safetensors
qwen3_5
turkish
türkiye
reasoning
vision-language
vlm
multimodal
lamapi
next2-air
qwen3.5
text-generation
open-source
2b
edge-ai
large-language-model
llm
thinking-mode
fast-inference
conversational
Instructions to use thelamapi/next2-air with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thelamapi/next2-air with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="thelamapi/next2-air") 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 AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("thelamapi/next2-air") model = AutoModelForImageTextToText.from_pretrained("thelamapi/next2-air") 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 = 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
- vLLM
How to use thelamapi/next2-air with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thelamapi/next2-air" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thelamapi/next2-air", "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/thelamapi/next2-air
- SGLang
How to use thelamapi/next2-air 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 "thelamapi/next2-air" \ --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": "thelamapi/next2-air", "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 "thelamapi/next2-air" \ --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": "thelamapi/next2-air", "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 thelamapi/next2-air with Docker Model Runner:
docker model run hf.co/thelamapi/next2-air
Update README.md
Browse files
README.md
CHANGED
|
@@ -182,59 +182,40 @@ Next2-Air features a highly capable visual encoder, allowing it to process spati
|
|
| 182 |
Make sure you have `transformers`, `torch`, `torchvision`, and `pillow` installed.
|
| 183 |
|
| 184 |
```python
|
| 185 |
-
from transformers import
|
| 186 |
-
import torch
|
| 187 |
from PIL import Image
|
| 188 |
-
import
|
| 189 |
-
|
| 190 |
-
model_id = "
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
processor = AutoProcessor.from_pretrained(model_id)
|
| 194 |
-
|
| 195 |
-
model_id,
|
| 196 |
-
torch_dtype=torch.float16,
|
| 197 |
-
device_map="auto" # Will easily load on almost any modern GPU
|
| 198 |
-
)
|
| 199 |
-
|
| 200 |
-
# Prepare Image
|
| 201 |
-
url = "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/RealWorld/RealWorld-04.png"
|
| 202 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
| 203 |
-
|
| 204 |
-
# Chat Template
|
| 205 |
-
messages =[
|
| 206 |
-
{
|
| 207 |
-
"role": "system",
|
| 208 |
-
"content": "Sen Next2-Air'sin. Lamapi tarafından Türkiye'de geliştirilmiş, hızlı ve akıllı bir yapay zekasın. Yanıtlarını düşünerek ve mantıklı bir şekilde ver."
|
| 209 |
-
},
|
| 210 |
-
{
|
| 211 |
-
"role": "user",
|
| 212 |
-
"content":[
|
| 213 |
-
{"type": "image", "image": image},
|
| 214 |
-
{"type": "text", "text": "Bu resimdeki temel objeleri ve sahneyi analiz eder misin?"}
|
| 215 |
-
]
|
| 216 |
-
}
|
| 217 |
-
]
|
| 218 |
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
)
|
| 230 |
-
|
| 231 |
-
# Decode
|
| 232 |
-
generated_ids_trimmed =[
|
| 233 |
-
out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 234 |
]
|
| 235 |
-
output_text = processor.batch_decode(generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 236 |
|
| 237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
```
|
| 239 |
|
| 240 |
---
|
|
|
|
| 182 |
Make sure you have `transformers`, `torch`, `torchvision`, and `pillow` installed.
|
| 183 |
|
| 184 |
```python
|
| 185 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoProcessor
|
|
|
|
| 186 |
from PIL import Image
|
| 187 |
+
import torch
|
| 188 |
+
|
| 189 |
+
model_id = "thelamapi/next2-air"
|
| 190 |
+
|
| 191 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 192 |
+
processor = AutoProcessor.from_pretrained(model_id) # For vision.
|
| 193 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
+
|
| 196 |
+
# Create a message in chat format
|
| 197 |
+
messages = [
|
| 198 |
+
{"role": "system","content": [{"type": "text", "text": "You are Next2 Air, a smart and concise AI assistant trained by Lamapi. Always respond in the user's language. Proudly made in Turkey."}]},
|
| 199 |
+
|
| 200 |
+
{
|
| 201 |
+
"role": "user","content": [
|
| 202 |
+
{"type": "text", "text": "Write a highly optimized Rust function to calculate the Fibonacci sequence using memoization"}
|
| 203 |
+
]
|
| 204 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
]
|
|
|
|
| 206 |
|
| 207 |
+
# Prepare input with Tokenizer
|
| 208 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=False)
|
| 209 |
+
inputs = processor(text=prompt, return_tensors="pt")
|
| 210 |
+
|
| 211 |
+
# Remove 'mm_token_type_ids' if it's not needed for text-only generation
|
| 212 |
+
if "mm_token_type_ids" in inputs:
|
| 213 |
+
del inputs["mm_token_type_ids"]
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
# Output from the model
|
| 217 |
+
output = model.generate(**inputs, do_sample=True, temperature=0.7, max_new_tokens=128)
|
| 218 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 219 |
```
|
| 220 |
|
| 221 |
---
|