aklai commited on
Commit
4629373
·
1 Parent(s): a81cab2

Update space

Browse files
Files changed (1) hide show
  1. app.py +5 -25
app.py CHANGED
@@ -18,32 +18,12 @@ from langchain_chroma import Chroma
18
  """
19
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
20
  """
 
 
 
 
 
21
 
22
- from langchain.llms.base import LLM
23
- from typing import Optional, List, Mapping, Any
24
- import subprocess
25
-
26
- class LlamaCppLLM(LLM):
27
- model_path: str # Path to the GGUF model
28
- n_ctx: int = 2048 # Context window size
29
-
30
- def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
31
- # Use llama.cpp to generate a response
32
- command = [
33
- "./main", # Path to llama.cpp executable
34
- "-m", self.model_path,
35
- "-p", prompt,
36
- "--ctx-size", str(self.n_ctx),
37
- ]
38
- result = subprocess.run(command, capture_output=True, text=True)
39
- return result.stdout
40
-
41
- @property
42
- def _llm_type(self) -> str:
43
- return "llama-cpp"
44
-
45
- # Initialize the custom LLM
46
- llm = LlamaCppLLM(model_path="path/to/bling-phi-3-gguf.bin")
47
 
48
  # Initialize embedding model "all-MiniLM-L6-v2"
49
  embedding_model = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
 
18
  """
19
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
20
  """
21
+ llm = HuggingFacePipeline.from_model_id(
22
+ model_id="meta-llama/Llama-3.2-3B",
23
+ task="text-generation",
24
+ pipeline_kwargs={"max_new_tokens": 10},
25
+ )
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  # Initialize embedding model "all-MiniLM-L6-v2"
29
  embedding_model = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")