Text Generation
Transformers
Safetensors
English
qwen2
chat
conversational
text-generation-inference
Instructions to use ritaberrada/iol-pipeline-test with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ritaberrada/iol-pipeline-test with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ritaberrada/iol-pipeline-test") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ritaberrada/iol-pipeline-test") model = AutoModelForCausalLM.from_pretrained("ritaberrada/iol-pipeline-test", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] 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 ritaberrada/iol-pipeline-test with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ritaberrada/iol-pipeline-test" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ritaberrada/iol-pipeline-test", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ritaberrada/iol-pipeline-test
- SGLang
How to use ritaberrada/iol-pipeline-test 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 "ritaberrada/iol-pipeline-test" \ --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": "ritaberrada/iol-pipeline-test", "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 "ritaberrada/iol-pipeline-test" \ --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": "ritaberrada/iol-pipeline-test", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ritaberrada/iol-pipeline-test with Docker Model Runner:
docker model run hf.co/ritaberrada/iol-pipeline-test
| import os | |
| os.environ["HF_HUB_OFFLINE"] = "1" | |
| os.environ["TRANSFORMERS_OFFLINE"] = "1" | |
| MODEL_ID = "." | |
| MODEL_NAME = "Qwen/Qwen2.5-1.5B-Instruct" | |
| import time, json, re | |
| import pandas as pd, torch | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| MAX_NEW_TOKENS = 1024 | |
| t0 = time.time() | |
| tok = AutoTokenizer.from_pretrained(MODEL_ID) | |
| model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.float16, device_map="auto").eval() | |
| print(f"[load] running {MODEL_NAME} from repo weights ({MODEL_ID})", flush=True) | |
| print(f"[load] model ready in {time.time()-t0:.0f}s", flush=True) | |
| df = pd.read_csv("/tmp/data/test.csv", dtype=str).fillna("") | |
| def extract_answers(text): | |
| # Prefer the section after "FINAL ANSWERS:" when present | |
| m = list(re.finditer(r'(?im)^[\s>*#-]*final answers?\s*[:.]?\s*$', text)) | |
| if m: | |
| text = text[m[-1].end():] | |
| # 1) answers on lines like [answer] (model asked to put only final answers there) | |
| br = [] | |
| for ln in text.splitlines(): | |
| ln = ln.strip() | |
| m = re.match(r'^\[(.+)\]$', ln) | |
| if m: | |
| br.append(m.group(1).strip()) | |
| if br: | |
| return br | |
| # 2) fallback: one cleaned answer per line | |
| out = [] | |
| for ln in text.splitlines(): | |
| ln = re.sub(r'^[\s>*#-]+', '', ln) | |
| ln = re.sub(r'^\d+[.)]\s*', '', ln).strip().strip("[]").strip() | |
| if ln: | |
| out.append(ln) | |
| return out | |
| SYSTEM = ("You solve International Linguistics Olympiad problems by reasoning from the data given. " | |
| "You may face a task type you have never seen — read the instruction and adapt. Answer in the " | |
| "language the task asks for; for matching items give the option letter, for number items give " | |
| "digits or the written-out number as asked. First reason briefly. Then write your FINAL ANSWERS: " | |
| "one per item, in the order the items appear, each wrapped in square brackets like " | |
| "[answer], and nothing else on those lines.") | |
| rows = [] | |
| for i, r in df.iterrows(): | |
| messages = [{"role": "system", "content": SYSTEM}, | |
| {"role": "user", "content": f"{r['context'].strip()}\n\n{r['query'].strip()}"}] | |
| ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device) | |
| with torch.no_grad(): | |
| out = model.generate(ids, max_new_tokens=MAX_NEW_TOKENS, do_sample=False) | |
| text = tok.decode(out[0][ids.shape[-1]:], skip_special_tokens=True).strip() | |
| answers = extract_answers(text) | |
| rows.append({"id": r["id"], "pred": json.dumps(answers, ensure_ascii=False)}) | |
| print(f"[{i+1}/{len(df)}] id={r['id']} -> {len(answers)} answers", flush=True) | |
| pd.DataFrame(rows).to_csv("submission.csv", index=False) | |
| print(f"[done] wrote submission.csv ({len(rows)} rows) in {time.time()-t0:.0f}s", flush=True) |