Downloads · 30 days
8
42% of all-time downloads
benradford/synthEDic
synthEDic is a text generation model from benradford. Use it when you need the model to write or continue text. It is set up for peft.
This model performs open-ended event data generation. Given input documents similar to newswire reporting, the model will output JSON-formatted event data similar to that found in ICEWS or GDELT.
Downloads · 30 days
8
42% of all-time downloads
All-time downloads
19
Public
Repo size
470 MB
Likes
0
Public
Click a slice to open those files.
.pt302 MB · 64%
From the Hugging Face model README
This model performs open-ended event data generation. Given input documents similar to newswire reporting, the model will output JSON-formatted event data similar to that found in ICEWS or GDELT.
from huggingface_hub import InferenceClient, login
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
pipeline
)
import torch
from peft import LoraConfig, PeftModel
## You will need to replace this with your Huggingface secret token
## The secret token is required to verify that you have permission
## to load the llama base model.
login(os.getenv("HF_TOKEN"))
## This is the current model.
model_name = "benradford/synthEDic"
## Quantization configuration.
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=getattr(torch, "float16"),
bnb_4bit_use_double_quant=False,
)
## Load llama, the base model
base_model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.1-8b-Instruct",
quantization_config=bnb_config
)
## Load the adapter model (synthEDic)
model = PeftModel.from_pretrained(base_model, model_name)
## Load the proper tokenizer from synthEDic
tokenizer = AutoTokenizer.from_pretrained(model_name, padding_side='right')
## Initialize a pipeline for inference
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
## Demo pipeline use:
output = pipe([{"role":"user","content":"Bob demanded concessions from Alice."}], max_new_tokens=256, num_beams=1, return_full_text=False)
print(output)
Note: In its current state (v0.4), this model will be very difficult to use. Proceed with caution.
The model will perform best if data are input in the following JSON-like format:
[{"roll":"user","content":<news like text>},...]
"assistant\n\n" to every output.The outputs can be processed into Python objects as below. This will require installing json_repair first.
It can be installed with pip install json_repair.
import json_repair
output = output.replace("assistant\n\n","")
output = json_repair.loads(output)