Maxmobi commited on
Commit
bd4907d
·
verified ·
1 Parent(s): b726fe8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -1
app.py CHANGED
@@ -1 +1,33 @@
1
- pip install llama-cpp-python
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ >>> from llama_cpp import Llama
2
+ >>> llm = Llama(
3
+ model_path="./models/7B/llama-model.gguf",
4
+ # n_gpu_layers=-1, # Uncomment to use GPU acceleration
5
+ # seed=1337, # Uncomment to set a specific seed
6
+ # n_ctx=2048, # Uncomment to increase the context window
7
+ )
8
+ >>> output = llm(
9
+ "Q: Name the planets in the solar system? A: ", # Prompt
10
+ max_tokens=32, # Generate up to 32 tokens, set to None to generate up to the end of the context window
11
+ stop=["Q:", "\n"], # Stop generating just before the model would generate a new question
12
+ echo=True # Echo the prompt back in the output
13
+ ) # Generate a completion, can also call create_completion
14
+ >>> print(output)
15
+ {
16
+ "id": "cmpl-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
17
+ "object": "text_completion",
18
+ "created": 1679561337,
19
+ "model": "./models/7B/llama-model.gguf",
20
+ "choices": [
21
+ {
22
+ "text": "Q: Name the planets in the solar system? A: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune and Pluto.",
23
+ "index": 0,
24
+ "logprobs": None,
25
+ "finish_reason": "stop"
26
+ }
27
+ ],
28
+ "usage": {
29
+ "prompt_tokens": 14,
30
+ "completion_tokens": 28,
31
+ "total_tokens": 42
32
+ }
33
+ }