Downloads · 30 days
39
3% of all-time downloads
Sandiago21/falcon-7b-prompt-answering
falcon-7b-prompt-answering is a text generation model from Sandiago21. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as other.
This repository contains further fine-tuned Falcon-7B model on conversations and question answering prompts.
Downloads · 30 days
39
3% of all-time downloads
All-time downloads
1.3K
Public
Repo size
23.7 GB
Likes
2
Public
Click a slice to open those files.
.bin19.1 GB · 81%
From the Hugging Face model README
This repository contains further fine-tuned Falcon-7B model on conversations and question answering prompts.
I used falcon-7b (https://huggingface.co/tiiuae/falcon-7b) as a base model, so this model has the same license with Falcon-7b model (Apache-2.0)
Anyone can use (ask prompts) and play with the model using the pre-existing Jupyter Notebook in the noteboooks folder. The Jupyter Notebook contains example code to load the model and ask prompts to it as well as example prompts to get you started.
The tiiuae/falcon-7b model was finetuned on conversations and question answering prompts.
Developed by: [More Information Needed]
Shared by: [More Information Needed]
Model type: Causal LM
Language(s) (NLP): English, multilingual
License: Apache-2.0
Finetuned from model: tiiuae/falcon-7b
Repository: [More Information Needed] Paper: [More Information Needed] Demo: [More Information Needed]
The model can be used for prompt answering
The model can be used for prompt answering
Generating text and prompt answering
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
The model was trained on the following kind of prompt:
def generate_prompt(prompt: str) -> str:
return f"""
<human>: {prompt}
<assistant>:
""".strip()
Use the code below to get started with the model.
import torch
from peft import PeftConfig, PeftModel
from transformers import GenerationConfig, AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
MODEL_NAME = "."
config = PeftConfig.from_pretrained(MODEL_NAME)
compute_dtype = getattr(torch, "float16")
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=compute_dtype,
bnb_4bit_use_double_quant=True,
)
model = AutoModelForCausalLM.from_pretrained(
config.base_model_name_or_path,
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = PeftModel.from_pretrained(model, MODEL_NAME)
generation_config = model.generation_config
generation_config.top_p = 0.7
generation_config.num_return_sequences = 1
generation_config.max_new_tokens = 32
generation_config.use_cache = False
generation_config.pad_token_id = tokenizer.eos_token_id
generation_config.eos_token_id = tokenizer.eos_token_id
model.eval()
if torch.__version__ >= "2":
model = torch.compile(model)
prompt = "What is the capital city of Greece and with which countries does Greece border?"
prompt = generate_prompt(prompt)
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
input_ids = input_ids.to(model.device)
with torch.no_grad():
outputs = model.generate(
input_ids=input_ids,
generation_config=generation_config,
return_dict_in_generate=True,
output_scores=True,
)
response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)
print(response)
>>> The capital city of Greece is Athens and it borders Albania, Bulgaria, Macedonia, and Turkey.
import torch
from peft import PeftConfig, PeftModel
from transformers import GenerationConfig, AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
MODEL_NAME = "Sandiago21/falcon-7b-prompt-answering"
BASE_MODEL = "tiiuae/falcon-7b"
compute_dtype = getattr(torch, "float16")
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=compute_dtype,
bnb_4bit_use_double_quant=True,
)
model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = PeftModel.from_pretrained(model, MODEL_NAME)
generation_config = model.generation_config
generation_config.top_p = 0.7
generation_config.num_return_sequences = 1
generation_config.max_new_tokens = 32
generation_config.use_cache = False
generation_config.pad_token_id = tokenizer.eos_token_id
generation_config.eos_token_id = tokenizer.eos_token_id
model.eval()
if torch.__version__ >= "2":
model = torch.compile(model)
prompt = "What is the capital city of Greece and with which countries does Greece border?"
prompt = generate_prompt(prompt)
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
input_ids = input_ids.to(model.device)
with torch.no_grad():
outputs = model.generate(
input_ids=input_ids,
generation_config=generation_config,
return_dict_in_generate=True,
output_scores=True,
)
response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)
print(response)
>>> The capital city of Greece is Athens and it borders Albania, Bulgaria, Macedonia, and Turkey.
The following hyperparameters were used during training:
The tiiuae/falcon-7b was finetuned on conversations and question answering data
The tiiuae/falcon-7b model was further trained and finetuned on question answering and prompts data for 1 epoch (approximately 10 hours of training on a single GPU)
The model is based on tiiuae/falcon-7b model and finetuned adapters on top of the main model on conversations and question answering data.