Spaces:
Runtime error
Runtime error
File size: 963 Bytes
06cf9c4 fabc6ce fa0a20e 4936389 06cf9c4 fa0a20e 06cf9c4 4936389 a10579d 360ead8 dcfcd56 a0c6b2f 884d32c a0c6b2f 06cf9c4 d3a9044 06cf9c4 dcfcd56 d3a9044 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
import time
import ctypes #to run on C api directly
import llama_cpp
from llama_cpp import Llama
from huggingface_hub import hf_hub_download #load from huggingfaces
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/airoboros-l2-13b-gpt4-m2.0-GGML", filename="airoboros-l2-13b-gpt4-m2.0.ggmlv3.q6_K.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
description = " Bro i dont want learn! i just want results(https://github.com/abetlen/llama-cpp-python)"
def generate_text(input_text):
output = llm(f"Q: {input_text} \n A:", max_tokens=1024, stop=["Q:", "\n"], echo=True,)
return output['choices'][0]['text']
input_text = gr.inputs.Textbox(lines= 10, label="Enter your input text")
output_text = gr.outputs.Textbox(label="Output text")
demo = gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title="Running Llama on CPU is Hard", description=description)
demo.launch()
|