Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Recipes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
meta-llama
Llama Recipes
Commits
f5e0ebdb
Commit
f5e0ebdb
authored
1 year ago
by
sekyonda
Browse files
Options
Downloads
Patches
Plain Diff
Update Llama2_Gradio.ipynb
parent
bc2d45aa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
demo_apps/Llama2_Gradio.ipynb
+1
-1
1 addition, 1 deletion
demo_apps/Llama2_Gradio.ipynb
with
1 addition
and
1 deletion
demo_apps/Llama2_Gradio.ipynb
+
1
−
1
View file @
f5e0ebdb
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
"\n",
"\n",
"**Note** After the free trial ends, you will need to enter billing info to continue to use Llama2 hosted on Replicate.\n",
"**Note** After the free trial ends, you will need to enter billing info to continue to use Llama2 hosted on Replicate.\n",
"\n",
"\n",
"To
t
un this example:\n",
"To
r
un this example:\n",
"- Set up your Replicate API token and enter it in place of `<your replicate api token>`\n",
"- Set up your Replicate API token and enter it in place of `<your replicate api token>`\n",
"- Run the notebook\n",
"- Run the notebook\n",
"- Enter your question and click Submit\n",
"- Enter your question and click Submit\n",
...
...
%% Cell type:markdown id:47a9adb3 tags:
%% Cell type:markdown id:47a9adb3 tags:
## This demo app shows how to query Llama 2 using the Gradio UI.
## This demo app shows how to query Llama 2 using the Gradio UI.
Since we are using Replicate in this example, you will need to replace
`<your replicate api token>`
with your API token.
Since we are using Replicate in this example, you will need to replace
`<your replicate api token>`
with your API token.
To get the Replicate token:
To get the Replicate token:
-
You will need to first sign in with Replicate with your github account
-
You will need to first sign in with Replicate with your github account
-
Then create a free API token
[
here
](
https://replicate.com/account/api-tokens
)
that you can use for a while.
-
Then create a free API token
[
here
](
https://replicate.com/account/api-tokens
)
that you can use for a while.
**Note**
After the free trial ends, you will need to enter billing info to continue to use Llama2 hosted on Replicate.
**Note**
After the free trial ends, you will need to enter billing info to continue to use Llama2 hosted on Replicate.
To
t
un this example:
To
r
un this example:
-
Set up your Replicate API token and enter it in place of
`<your replicate api token>`
-
Set up your Replicate API token and enter it in place of
`<your replicate api token>`
-
Run the notebook
-
Run the notebook
-
Enter your question and click Submit
-
Enter your question and click Submit
In the notebook or a browser with URL http://127.0.0.1:7860 you should see a UI with your answer.
In the notebook or a browser with URL http://127.0.0.1:7860 you should see a UI with your answer.
%% Cell type:code id:928041cc tags:
%% Cell type:code id:928041cc tags:
```
python
```
python
from
langchain.schema
import
AIMessage
,
HumanMessage
from
langchain.schema
import
AIMessage
,
HumanMessage
import
gradio
as
gr
import
gradio
as
gr
from
langchain.llms
import
Replicate
from
langchain.llms
import
Replicate
import
os
import
os
os
.
environ
[
"
REPLICATE_API_TOKEN
"
]
=
"
<your replicate api token>
"
os
.
environ
[
"
REPLICATE_API_TOKEN
"
]
=
"
<your replicate api token>
"
llama2_13b_chat
=
"
meta/llama-2-13b-chat:f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d
"
llama2_13b_chat
=
"
meta/llama-2-13b-chat:f4e2de70d66816a838a89eeeb621910adffb0dd0baba3976c96980970978018d
"
llm
=
Replicate
(
llm
=
Replicate
(
model
=
llama2_13b_chat
,
model
=
llama2_13b_chat
,
model_kwargs
=
{
"
temperature
"
:
0.01
,
"
top_p
"
:
1
,
"
max_new_tokens
"
:
500
}
model_kwargs
=
{
"
temperature
"
:
0.01
,
"
top_p
"
:
1
,
"
max_new_tokens
"
:
500
}
)
)
def
predict
(
message
,
history
):
def
predict
(
message
,
history
):
history_langchain_format
=
[]
history_langchain_format
=
[]
for
human
,
ai
in
history
:
for
human
,
ai
in
history
:
history_langchain_format
.
append
(
HumanMessage
(
content
=
human
))
history_langchain_format
.
append
(
HumanMessage
(
content
=
human
))
history_langchain_format
.
append
(
AIMessage
(
content
=
ai
))
history_langchain_format
.
append
(
AIMessage
(
content
=
ai
))
history_langchain_format
.
append
(
HumanMessage
(
content
=
message
))
history_langchain_format
.
append
(
HumanMessage
(
content
=
message
))
gpt_response
=
llm
(
message
)
#history_langchain_format)
gpt_response
=
llm
(
message
)
#history_langchain_format)
return
gpt_response
#.content
return
gpt_response
#.content
gr
.
ChatInterface
(
predict
).
launch
()
gr
.
ChatInterface
(
predict
).
launch
()
```
```
%% Output
%% Output
Init param `input` is deprecated, please use `model_kwargs` instead.
Init param `input` is deprecated, please use `model_kwargs` instead.
Running on local URL: http://127.0.0.1:7860
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
To create a public link, set `share=True` in `launch()`.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment