valendra/andalusian-synthetic
Viewer • Updated • 2k • 15
How to use valendra/qwen3.5-4b-andalusian with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="valendra/qwen3.5-4b-andalusian")
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("valendra/qwen3.5-4b-andalusian")
model = AutoModelForImageTextToText.from_pretrained("valendra/qwen3.5-4b-andalusian")
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]:]))How to use valendra/qwen3.5-4b-andalusian with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "valendra/qwen3.5-4b-andalusian"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "valendra/qwen3.5-4b-andalusian",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/valendra/qwen3.5-4b-andalusian
How to use valendra/qwen3.5-4b-andalusian with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "valendra/qwen3.5-4b-andalusian" \
--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": "valendra/qwen3.5-4b-andalusian",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "valendra/qwen3.5-4b-andalusian" \
--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": "valendra/qwen3.5-4b-andalusian",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use valendra/qwen3.5-4b-andalusian with Docker Model Runner:
docker model run hf.co/valendra/qwen3.5-4b-andalusian
valendra/qwen3.5-4b-andalusian es una adaptación de Qwen/Qwen3.5-4B orientada a responder en español sobre temas relacionados con Andalucía.
El modelo se ha afinado con el dataset valendra/andalusian-synthetic.
En pruebas cualitativas manuales, esta versión tiende a rendir mejor que Qwen/Qwen3.5-4B en preguntas sobre Andalucía.
Las mejoras más visibles son:
Ejemplos de mejora observada:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "valendra/qwen3.5-4b-andalusian"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype="auto",
device_map="auto",
trust_remote_code=True,
)
messages = [
{
"role": "user",
"content": "¿Qué papel tuvo Blas Infante en el andalucismo y qué hechos históricos lo respaldan?"
}
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=400,
temperature=0.2,
do_sample=True,
)
response = tokenizer.decode(
outputs[0][inputs["input_ids"].shape[1]:],
skip_special_tokens=True,
)
print(response)
from transformers import pipeline
pipe = pipeline(
"text-generation",
model="valendra/qwen3.5-4b-andalusian",
tokenizer="valendra/qwen3.5-4b-andalusian",
trust_remote_code=True,
device_map="auto",
)
messages = [
{"role": "user", "content": "Explícame qué es el flamenco y por qué es importante en Andalucía."}
]
result = pipe(messages, max_new_tokens=300, temperature=0.2, do_sample=True)
print(result[0]["generated_text"][-1]["content"])
¿Qué papel tuvo Blas Infante en el andalucismo y qué hechos históricos lo respaldan?
¿Qué papel tuvo la ciudad de Cádiz en la promulgación de la Constitución de 1812 y cómo se recuerda en la tradición oral?
¿Cómo se explica la evolución del flamenco desde sus raíces hasta la actualidad, diferenciando historia y tradición?
¿Cómo influye la memoria popular en la identidad andaluza sin confundirla con hechos documentados?