Instructions to use fractalego/fact-checking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fractalego/fact-checking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fractalego/fact-checking")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("fractalego/fact-checking") model = AutoModelForCausalLM.from_pretrained("fractalego/fact-checking") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use fractalego/fact-checking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fractalego/fact-checking" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fractalego/fact-checking", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/fractalego/fact-checking
- SGLang
How to use fractalego/fact-checking 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 "fractalego/fact-checking" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fractalego/fact-checking", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "fractalego/fact-checking" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fractalego/fact-checking", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use fractalego/fact-checking with Docker Model Runner:
docker model run hf.co/fractalego/fact-checking
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Fact checking
This generative model - trained on FEVER - aims to predict whether a claim is consistent with the provided evidence.
Installation and simple usage
One quick way to install it is to type
pip install fact_checking
and then use the following code:
from transformers import (
GPT2LMHeadModel,
GPT2Tokenizer,
)
from fact_checking import FactChecker
_evidence = """
Justine Tanya Bateman (born February 19, 1966) is an American writer, producer, and actress . She is best known for her regular role as Mallory Keaton on the sitcom Family Ties (1982 -- 1989). Until recently, Bateman ran a production and consulting company, SECTION 5 . In the fall of 2012, she started studying computer science at UCLA.
"""
_claim = 'Justine Bateman is a poet.'
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
fact_checking_model = GPT2LMHeadModel.from_pretrained('fractalego/fact-checking')
fact_checker = FactChecker(fact_checking_model, tokenizer)
is_claim_true = fact_checker.validate(_evidence, _claim)
print(is_claim_true)
which gives the output
False
Probabilistic output with replicas
The output can include a probabilistic component, obtained by iterating a number of times the output generation. The system generates an ensemble of answers and groups them by Yes or No.
For example, one can ask
from transformers import (
GPT2LMHeadModel,
GPT2Tokenizer,
)
from fact_checking import FactChecker
_evidence = """
Jane writes code for Huggingface.
"""
_claim = 'Jane is an engineer.'
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
fact_checking_model = GPT2LMHeadModel.from_pretrained('fractalego/fact-checking')
fact_checker = FactChecker(fact_checking_model, tokenizer)
is_claim_true = fact_checker.validate_with_replicas(_evidence, _claim)
print(is_claim_true)
with output
{'Y': 0.95, 'N': 0.05}
Score on FEVER
The predictions are evaluated on a subset of the FEVER dev dataset, restricted to the SUPPORTING and REFUTING options:
| precision | recall | F1 |
|---|---|---|
| 0.94 | 0.98 | 0.96 |
These results should be taken with many grains of salt. This is still a work in progress, and there might be leakage coming from the underlining GPT2 model unnaturally raising the scores.
- Downloads last month
- 2,149