Text Generation
Transformers
Safetensors
Korean
English
qwen3_5
image-text-to-text
fact-checking
claim-verification
nli
grounding
factguard
conversational
Instructions to use ThakiCloud/FactGuard-General-4B-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ThakiCloud/FactGuard-General-4B-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ThakiCloud/FactGuard-General-4B-v2") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ThakiCloud/FactGuard-General-4B-v2") model = AutoModelForMultimodalLM.from_pretrained("ThakiCloud/FactGuard-General-4B-v2", 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 = 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ThakiCloud/FactGuard-General-4B-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ThakiCloud/FactGuard-General-4B-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ThakiCloud/FactGuard-General-4B-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ThakiCloud/FactGuard-General-4B-v2
- SGLang
How to use ThakiCloud/FactGuard-General-4B-v2 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 "ThakiCloud/FactGuard-General-4B-v2" \ --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": "ThakiCloud/FactGuard-General-4B-v2", "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 "ThakiCloud/FactGuard-General-4B-v2" \ --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": "ThakiCloud/FactGuard-General-4B-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ThakiCloud/FactGuard-General-4B-v2 with Docker Model Runner:
docker model run hf.co/ThakiCloud/FactGuard-General-4B-v2
Download example_inference.py from ThakiCloud/FactGuard-General-4B-v2: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/ThakiCloud/FactGuard-General-4B-v2/resolve/main/example_inference.py
- Command line
-
hf download hf://ThakiCloud/FactGuard-General-4B-v2/example_inference.py
-
curl -L -o example_inference.py https://huggingface.co/ThakiCloud/FactGuard-General-4B-v2/resolve/main/example_inference.py
1.26 kB
| """Minimal FactGuard-General-4B-v2 inference: label probabilities for one claim against evidence lines.""" | |
| import json, torch | |
| from huggingface_hub import hf_hub_download | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| REPO = "ThakiCloud/FactGuard-General-4B-v2" | |
| contract = json.load(open(hf_hub_download(REPO, "label_contract.json"))) | |
| HEAD = contract["head_general"] | |
| LABELS = ["SUPPORTED", "CONTRADICTED", "NOT_VERIFIABLE", "STALE"] | |
| tok = AutoTokenizer.from_pretrained(REPO) | |
| model = AutoModelForCausalLM.from_pretrained(REPO, dtype=torch.bfloat16, device_map="auto").eval() | |
| label_ids = [tok.encode(" " + t, add_special_tokens=False)[0] for t in "ABCD"] | |
| packet = ("대상: 회사 공지\n근거:\n" | |
| "F1: [공지] 서울 사무소는 2026년 3월 2일부터 판교로 이전한다.\n" | |
| "F2: [공지] 이전 기간 중 고객센터 전화는 정상 운영한다.\n" | |
| "주장: 이전 기간에는 고객센터 전화가 중단된다.") | |
| ids = tok.encode(HEAD + packet + "\n\n판정:", add_special_tokens=False)[-1024:] | |
| with torch.no_grad(): | |
| logits = model(torch.tensor([ids], device=model.device)).logits[0, -1, label_ids].float() | |
| print(dict(zip(LABELS, [round(p, 4) for p in torch.softmax(logits, -1).tolist()]))) | |