Downloads · 30 days
9
4% of all-time downloads
lstama/karina
karina is a text generation model from lstama. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as bigscience-bloom-rail-1.0.
Downloads · 30 days
9
4% of all-time downloads
All-time downloads
223
Public
Repo size
30 GB
Likes
0
Public
Click a slice to open those files.
.bin6 GB · 100%
From the Hugging Face model README
We present KARINA, finetuned from BLOOMZ bigscience/bloomz-3b, a family of models capable of following human instructions in dozens of languages zero-shot. We finetune BLOOMZ pretrained multilingual language models on our crosslingual task mixture (xP3) and find the resulting models capable of crosslingual generalization to unseen tasks & languages.
We recommend using the model to perform tasks expressed in natural language. For example, given the prompt "prompt = f"Given the question:\n{{ siapa kamu? }}\n---\nAnswer:\n"", the model will most likely answer "Saya Karina. Ada yang bisa saya bantu?".
# pip install -q transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_NAME = "yodi/karina"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
inputs = tokenizer.encode("Given the question:\n{{ siapa kamu? }}\n---\nAnswer:\n", return_tensors="pt")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
</details>
# pip install -q transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers import pipeline
MODEL_NAME = "yodi/karina"
model_4bit = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="cuda:1", load_in_4bit=True)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
prompt = f"Given the question:\n{{ siapa kamu? }}\n---\nAnswer:\n"
generator = pipeline('text-generation',
model=model_4bit,
tokenizer=tokenizer,
do_sample=False)
result = generator(prompt, max_length=256)
print(result)
</details>
# pip install -q transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers import pipeline
MODEL_NAME = "yodi/karina"
model_4bit = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="cuda:1", load_in_8bit=True)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
prompt = f"Given the question:\n{{ siapa kamu? }}\n---\nAnswer:\n"
generator = pipeline('text-generation',
model=model_4bit,
tokenizer=tokenizer,
do_sample=False)
result = generator(prompt, max_length=256)
print(result)
</details>
[{'generated_text': 'Given the question:\n{ siapa kamu? }\n---\nAnswer:\nSaya Karina, asisten virtual siap membantu seputar estimasi harga atau pertanyaan lain'}]
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers import pipeline
import re
import gradio as gr
MODEL_NAME = "yodi/karina"
model_4bit = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="cuda:1", load_in_4bit=True)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
prompt = f"Given the question:\n{{ siapa kamu? }}\n---\nAnswer:\n"
generator = pipeline('text-generation',
model=model_4bit,
tokenizer=tokenizer,
do_sample=False)
def preprocess(text):
return f"Given the question:\n{{ {text} }}\n---\nAnswer:\n"
def generate(text):
preprocess_result = preprocess(text)
result = generator(preprocess_result, max_length=256)
output = re.split(r'\Given the question:|Answer:|Answer #|Title:',result[0]['generated_text'])[2]
return output
with gr.Blocks() as demo:
input_text = gr.Textbox(label="Input", lines=1)
button = gr.Button("Submit")
output_text = gr.Textbox(lines=6, label="Output")
button.click(generate, inputs=[input_text], outputs=output_text)
demo.launch(enable_queue=True, debug=True)
And open the gradio url from browser.
The following bitsandbytes quantization config was used during training:
Prompt Engineering: The performance may vary depending on the prompt and its following BLOOMZ models.
config.json file