Skip to content

Instantly share code, notes, and snippets.

@ag-chirag
Created September 24, 2024 03:10
Show Gist options
  • Save ag-chirag/8383a302d03abd4e546df0b4911b0520 to your computer and use it in GitHub Desktop.
Save ag-chirag/8383a302d03abd4e546df0b4911b0520 to your computer and use it in GitHub Desktop.
Loading Data Gemma from HuggingFace
class DataGemma:
def __init__(self, model_id: str = "bartowski/datagemma-rag-27b-it-GGUF", model_file: str = "datagemma-rag-27b-it-Q2_K.gguf"):
self.generation_kwargs = {
"max_tokens": 4096, # Max number of new tokens to generate
}
self.model_path = hf_hub_download(model_id, model_file)
self.llm = Llama(
self.model_path
)
self.name = "DataGemma"
def complete(self, question: str) -> str:
llm_resp = self.llm(question, **self.generation_kwargs)
return llm_resp["choices"][0]["text"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment