Spaces:
Sleeping
Sleeping
File size: 1,467 Bytes
9c7e22f 0ffcc97 29d374a 0ffcc97 cf8ca80 0ffcc97 cf8ca80 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import streamlit as st
from llama_cpp import Llama
llm = Llama.from_pretrained(
repo_id="Mykes/med_gemma7b_gguf",
filename="*Q4_K_M.gguf",
verbose=False
)
input_text = st.textarea('text')
if text:
output = llm(
input_text, # Prompt
max_tokens=32, # Generate up to 32 tokens, set to None to generate up to the end of the context window
stop=["Q:", "\n"], # Stop generating just before the model would generate a new question
echo=True # Echo the prompt back in the output
) # Generate a completion, can also call create_completion
st.write(outputs)
# from ctransformers import AutoModelForCausalLM, AutoTokenizer
# model = AutoModelForCausalLM.from_pretrained("Mykes/med_gemma7b_gguf", model_file="unsloth.Q4_K_M.gguf")
# tokenizer = AutoTokenizer.from_pretrained(model)
# input_text = st.textarea('text')
# if text:
# input_ids = tokenizer(input_text, return_tensors="pt")
# outputs = model.generate(**input_ids)
# st.write(outputs)
# from transformers import AutoTokenizer, AutoModelForCausalLM
# model_id = "Mykes/med_gemma7b_gguf"
# filename = "unsloth.Q4_K_M.gguf"
# tokenizer = AutoTokenizer.from_pretrained(model_id, gguf_file=filename)
# model = AutoModelForCausalLM.from_pretrained(model_id, gguf_file=filename)
# input_text = st.textarea('text')
# if text:
# input_ids = tokenizer(input_text, return_tensors="pt")
# outputs = model.generate(**input_ids)
# st.write(outputs) |