Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- .github/workflows/update_space.yml +28 -0
- .gitignore +162 -0
- README.md +26 -12
- chat_test.ipynb +531 -0
- interactive_test.py +71 -0
- requirements.txt +1 -0
.github/workflows/update_space.yml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Run Python script
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- main
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
build:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
- name: Checkout
|
14 |
+
uses: actions/checkout@v2
|
15 |
+
|
16 |
+
- name: Set up Python
|
17 |
+
uses: actions/setup-python@v2
|
18 |
+
with:
|
19 |
+
python-version: '3.9'
|
20 |
+
|
21 |
+
- name: Install Gradio
|
22 |
+
run: python -m pip install gradio
|
23 |
+
|
24 |
+
- name: Log in to Hugging Face
|
25 |
+
run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
|
26 |
+
|
27 |
+
- name: Deploy to Spaces
|
28 |
+
run: gradio deploy
|
.gitignore
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
share/python-wheels/
|
24 |
+
*.egg-info/
|
25 |
+
.installed.cfg
|
26 |
+
*.egg
|
27 |
+
MANIFEST
|
28 |
+
|
29 |
+
# PyInstaller
|
30 |
+
# Usually these files are written by a python script from a template
|
31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32 |
+
*.manifest
|
33 |
+
*.spec
|
34 |
+
|
35 |
+
# Installer logs
|
36 |
+
pip-log.txt
|
37 |
+
pip-delete-this-directory.txt
|
38 |
+
|
39 |
+
# Unit test / coverage reports
|
40 |
+
htmlcov/
|
41 |
+
.tox/
|
42 |
+
.nox/
|
43 |
+
.coverage
|
44 |
+
.coverage.*
|
45 |
+
.cache
|
46 |
+
nosetests.xml
|
47 |
+
coverage.xml
|
48 |
+
*.cover
|
49 |
+
*.py,cover
|
50 |
+
.hypothesis/
|
51 |
+
.pytest_cache/
|
52 |
+
cover/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
.pybuilder/
|
76 |
+
target/
|
77 |
+
|
78 |
+
# Jupyter Notebook
|
79 |
+
.ipynb_checkpoints
|
80 |
+
|
81 |
+
# IPython
|
82 |
+
profile_default/
|
83 |
+
ipython_config.py
|
84 |
+
|
85 |
+
# pyenv
|
86 |
+
# For a library or package, you might want to ignore these files since the code is
|
87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
88 |
+
# .python-version
|
89 |
+
|
90 |
+
# pipenv
|
91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94 |
+
# install all needed dependencies.
|
95 |
+
#Pipfile.lock
|
96 |
+
|
97 |
+
# poetry
|
98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
100 |
+
# commonly ignored for libraries.
|
101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
102 |
+
#poetry.lock
|
103 |
+
|
104 |
+
# pdm
|
105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
106 |
+
#pdm.lock
|
107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
108 |
+
# in version control.
|
109 |
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
110 |
+
.pdm.toml
|
111 |
+
.pdm-python
|
112 |
+
.pdm-build/
|
113 |
+
|
114 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
115 |
+
__pypackages__/
|
116 |
+
|
117 |
+
# Celery stuff
|
118 |
+
celerybeat-schedule
|
119 |
+
celerybeat.pid
|
120 |
+
|
121 |
+
# SageMath parsed files
|
122 |
+
*.sage.py
|
123 |
+
|
124 |
+
# Environments
|
125 |
+
.env
|
126 |
+
.venv
|
127 |
+
env/
|
128 |
+
venv/
|
129 |
+
ENV/
|
130 |
+
env.bak/
|
131 |
+
venv.bak/
|
132 |
+
|
133 |
+
# Spyder project settings
|
134 |
+
.spyderproject
|
135 |
+
.spyproject
|
136 |
+
|
137 |
+
# Rope project settings
|
138 |
+
.ropeproject
|
139 |
+
|
140 |
+
# mkdocs documentation
|
141 |
+
/site
|
142 |
+
|
143 |
+
# mypy
|
144 |
+
.mypy_cache/
|
145 |
+
.dmypy.json
|
146 |
+
dmypy.json
|
147 |
+
|
148 |
+
# Pyre type checker
|
149 |
+
.pyre/
|
150 |
+
|
151 |
+
# pytype static type analyzer
|
152 |
+
.pytype/
|
153 |
+
|
154 |
+
# Cython debug symbols
|
155 |
+
cython_debug/
|
156 |
+
|
157 |
+
# PyCharm
|
158 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
159 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
160 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
161 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
162 |
+
#.idea/
|
README.md
CHANGED
@@ -1,12 +1,26 @@
|
|
1 |
-
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: demo_human_gpt
|
3 |
+
app_file: interactive_test.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 4.43.0
|
6 |
+
---
|
7 |
+
# HumanGPT Game Test
|
8 |
+
<a target="_blank" href="https://colab.research.google.com/github/bldng1337/human_gpt_technical_test/blob/main/chat_test.ipynb">
|
9 |
+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
|
10 |
+
</a>
|
11 |
+
|
12 |
+
This is a Test of the feasibility of letting an LLM generate the user part while the bot part is written by the user.
|
13 |
+
|
14 |
+
We won't instruct the language model to roleplay as a user. Instead, we'll instruct it to generate the bot's responses as it was trained to do. Then, we let the model complete the user text blocks. Since the model doesn't distinguish between writing bot or user parts, we should be able to leverage its full training instead of trying to get it to rp which it was not trained for. Should also make gaslighting/confusing the model harder as its not pretending to be a user but should belive it is.
|
15 |
+
|
16 |
+
## How to use
|
17 |
+
Press the "Open in Colab" button to open the notebook in Google Colab.
|
18 |
+
|
19 |
+
## TODO
|
20 |
+
- Make a chatwindow with panel to test the model interactively
|
21 |
+
- test multiple backs and forths
|
22 |
+
|
23 |
+
## Models to compare/try:
|
24 |
+
- https://huggingface.co/ArliAI/Llama-3.1-8B-ArliAI-RPMax-v1.1-GGUF
|
25 |
+
- https://huggingface.co/ArliAI/Phi-3.5-mini-3.8B-ArliAI-RPMax-v1.1-GGUF
|
26 |
+
- https://huggingface.co/google/gemma-2-2b-it-GGUF
|
chat_test.ipynb
ADDED
@@ -0,0 +1,531 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"^C\n",
|
13 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
14 |
+
]
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"name": "stderr",
|
18 |
+
"output_type": "stream",
|
19 |
+
"text": [
|
20 |
+
"\n",
|
21 |
+
"[notice] A new release of pip is available: 23.1.2 -> 24.2\n",
|
22 |
+
"[notice] To update, run: python.exe -m pip install --upgrade pip\n"
|
23 |
+
]
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"name": "stdout",
|
27 |
+
"output_type": "stream",
|
28 |
+
"text": [
|
29 |
+
"Collecting llama-cpp-python\n",
|
30 |
+
" Downloading llama_cpp_python-0.2.90.tar.gz (63.8 MB)\n",
|
31 |
+
" 0.0/63.8 MB ? eta -:--:--\n",
|
32 |
+
" 0.0/63.8 MB 960.0 kB/s eta 0:01:07\n",
|
33 |
+
" 0.2/63.8 MB 2.1 MB/s eta 0:00:31\n",
|
34 |
+
" 0.4/63.8 MB 2.9 MB/s eta 0:00:23\n",
|
35 |
+
" 0.7/63.8 MB 3.8 MB/s eta 0:00:17\n",
|
36 |
+
" 1.1/63.8 MB 5.0 MB/s eta 0:00:13\n",
|
37 |
+
" 1.3/63.8 MB 4.9 MB/s eta 0:00:13\n",
|
38 |
+
" - 1.8/63.8 MB 5.6 MB/s eta 0:00:12\n",
|
39 |
+
" - 1.9/63.8 MB 5.1 MB/s eta 0:00:13\n",
|
40 |
+
" - 2.1/63.8 MB 5.2 MB/s eta 0:00:12\n",
|
41 |
+
" - 2.6/63.8 MB 5.8 MB/s eta 0:00:11\n",
|
42 |
+
" - 3.0/63.8 MB 5.9 MB/s eta 0:00:11\n",
|
43 |
+
" -- 3.5/63.8 MB 6.3 MB/s eta 0:00:10\n",
|
44 |
+
" -- 3.9/63.8 MB 6.6 MB/s eta 0:00:10\n",
|
45 |
+
" -- 4.5/63.8 MB 7.0 MB/s eta 0:00:09\n",
|
46 |
+
" --- 4.9/63.8 MB 7.1 MB/s eta 0:00:09\n",
|
47 |
+
" --- 5.1/63.8 MB 7.1 MB/s eta 0:00:09\n",
|
48 |
+
" --- 5.5/63.8 MB 7.0 MB/s eta 0:00:09\n",
|
49 |
+
" --- 5.9/63.8 MB 7.1 MB/s eta 0:00:09\n",
|
50 |
+
" ---- 6.4/63.8 MB 7.3 MB/s eta 0:00:08\n",
|
51 |
+
" ---- 6.7/63.8 MB 7.3 MB/s eta 0:00:08\n",
|
52 |
+
" ---- 7.2/63.8 MB 7.4 MB/s eta 0:00:08\n",
|
53 |
+
" ---- 7.5/63.8 MB 7.4 MB/s eta 0:00:08\n",
|
54 |
+
" ----- 8.0/63.8 MB 7.6 MB/s eta 0:00:08\n",
|
55 |
+
" ----- 8.6/63.8 MB 7.7 MB/s eta 0:00:08\n",
|
56 |
+
" ----- 9.1/63.8 MB 7.8 MB/s eta 0:00:07\n",
|
57 |
+
" ------ 9.6/63.8 MB 8.0 MB/s eta 0:00:07\n",
|
58 |
+
" ------ 9.9/63.8 MB 7.9 MB/s eta 0:00:07\n",
|
59 |
+
" ------ 10.6/63.8 MB 8.7 MB/s eta 0:00:07\n",
|
60 |
+
" ------ 11.1/63.8 MB 9.0 MB/s eta 0:00:06\n",
|
61 |
+
" ------- 11.5/63.8 MB 9.1 MB/s eta 0:00:06\n",
|
62 |
+
" ------- 11.9/63.8 MB 9.1 MB/s eta 0:00:06\n",
|
63 |
+
" ------- 12.6/63.8 MB 9.8 MB/s eta 0:00:06\n",
|
64 |
+
" -------- 13.1/63.8 MB 9.8 MB/s eta 0:00:06\n",
|
65 |
+
" -------- 13.5/63.8 MB 9.8 MB/s eta 0:00:06\n",
|
66 |
+
" -------- 13.9/63.8 MB 9.8 MB/s eta 0:00:06\n",
|
67 |
+
" -------- 14.3/63.8 MB 9.8 MB/s eta 0:00:06\n",
|
68 |
+
" --------- 14.8/63.8 MB 9.6 MB/s eta 0:00:06\n",
|
69 |
+
" --------- 15.4/63.8 MB 10.2 MB/s eta 0:00:05\n",
|
70 |
+
" --------- 16.1/63.8 MB 10.4 MB/s eta 0:00:05\n",
|
71 |
+
" ---------- 16.6/63.8 MB 10.4 MB/s eta 0:00:05\n",
|
72 |
+
" ---------- 16.6/63.8 MB 9.9 MB/s eta 0:00:05\n",
|
73 |
+
" ---------- 17.0/63.8 MB 10.1 MB/s eta 0:00:05\n",
|
74 |
+
" ---------- 17.7/63.8 MB 10.4 MB/s eta 0:00:05\n",
|
75 |
+
" ----------- 18.4/63.8 MB 10.6 MB/s eta 0:00:05\n",
|
76 |
+
" ----------- 18.9/63.8 MB 10.6 MB/s eta 0:00:05\n",
|
77 |
+
" ----------- 19.4/63.8 MB 10.6 MB/s eta 0:00:05\n",
|
78 |
+
" ------------ 19.9/63.8 MB 10.7 MB/s eta 0:00:05\n",
|
79 |
+
" ------------ 20.3/63.8 MB 10.7 MB/s eta 0:00:05\n",
|
80 |
+
" ------------ 20.8/63.8 MB 10.4 MB/s eta 0:00:05\n",
|
81 |
+
" ------------- 21.4/63.8 MB 10.6 MB/s eta 0:00:05\n",
|
82 |
+
" ------------- 21.9/63.8 MB 10.7 MB/s eta 0:00:04\n",
|
83 |
+
" ------------- 22.5/63.8 MB 10.7 MB/s eta 0:00:04\n",
|
84 |
+
" ------------- 22.9/63.8 MB 10.6 MB/s eta 0:00:04\n",
|
85 |
+
" -------------- 23.5/63.8 MB 10.6 MB/s eta 0:00:04\n",
|
86 |
+
" -------------- 23.7/63.8 MB 10.4 MB/s eta 0:00:04\n",
|
87 |
+
" -------------- 24.1/63.8 MB 10.6 MB/s eta 0:00:04\n",
|
88 |
+
" -------------- 24.4/63.8 MB 10.4 MB/s eta 0:00:04\n",
|
89 |
+
" --------------- 24.8/63.8 MB 10.2 MB/s eta 0:00:04\n",
|
90 |
+
" --------------- 25.2/63.8 MB 10.2 MB/s eta 0:00:04\n",
|
91 |
+
" ---------------- 25.7/63.8 MB 9.9 MB/s eta 0:00:04\n",
|
92 |
+
" ---------------- 26.2/63.8 MB 9.9 MB/s eta 0:00:04\n",
|
93 |
+
" ---------------- 26.6/63.8 MB 9.8 MB/s eta 0:00:04\n",
|
94 |
+
" ---------------- 26.9/63.8 MB 10.1 MB/s eta 0:00:04\n",
|
95 |
+
" ---------------- 27.3/63.8 MB 10.1 MB/s eta 0:00:04\n",
|
96 |
+
" ----------------- 27.8/63.8 MB 9.9 MB/s eta 0:00:04\n",
|
97 |
+
" ----------------- 28.3/63.8 MB 9.8 MB/s eta 0:00:04\n",
|
98 |
+
" ----------------- 28.7/63.8 MB 9.6 MB/s eta 0:00:04\n",
|
99 |
+
" ------------------ 29.0/63.8 MB 9.4 MB/s eta 0:00:04\n",
|
100 |
+
" ------------------ 29.2/63.8 MB 9.2 MB/s eta 0:00:04\n",
|
101 |
+
" ------------------ 29.7/63.8 MB 9.4 MB/s eta 0:00:04\n",
|
102 |
+
" ------------------ 30.1/63.8 MB 9.1 MB/s eta 0:00:04\n",
|
103 |
+
" ------------------- 30.3/63.8 MB 8.8 MB/s eta 0:00:04\n",
|
104 |
+
" ------------------- 30.8/63.8 MB 9.0 MB/s eta 0:00:04\n",
|
105 |
+
" ------------------- 31.0/63.8 MB 8.7 MB/s eta 0:00:04\n",
|
106 |
+
" ------------------- 31.3/63.8 MB 8.5 MB/s eta 0:00:04\n",
|
107 |
+
" ------------------- 31.6/63.8 MB 8.4 MB/s eta 0:00:04\n",
|
108 |
+
" -------------------- 32.0/63.8 MB 8.4 MB/s eta 0:00:04\n",
|
109 |
+
" -------------------- 32.4/63.8 MB 8.3 MB/s eta 0:00:04\n",
|
110 |
+
" -------------------- 32.9/63.8 MB 8.3 MB/s eta 0:00:04\n",
|
111 |
+
" -------------------- 33.3/63.8 MB 8.3 MB/s eta 0:00:04\n",
|
112 |
+
" --------------------- 33.7/63.8 MB 8.1 MB/s eta 0:00:04\n",
|
113 |
+
" --------------------- 34.2/63.8 MB 8.3 MB/s eta 0:00:04\n",
|
114 |
+
" --------------------- 34.7/63.8 MB 8.5 MB/s eta 0:00:04\n",
|
115 |
+
" ---------------------- 35.1/63.8 MB 8.5 MB/s eta 0:00:04\n",
|
116 |
+
" ---------------------- 35.5/63.8 MB 8.5 MB/s eta 0:00:04\n",
|
117 |
+
" ---------------------- 36.0/63.8 MB 8.4 MB/s eta 0:00:04\n",
|
118 |
+
" ---------------------- 36.3/63.8 MB 8.3 MB/s eta 0:00:04\n",
|
119 |
+
" ----------------------- 36.8/63.8 MB 8.4 MB/s eta 0:00:04\n",
|
120 |
+
" ----------------------- 37.2/63.8 MB 8.5 MB/s eta 0:00:04\n",
|
121 |
+
" ----------------------- 37.6/63.8 MB 8.5 MB/s eta 0:00:04\n",
|
122 |
+
" ----------------------- 38.1/63.8 MB 8.4 MB/s eta 0:00:04\n",
|
123 |
+
" ------------------------ 38.6/63.8 MB 8.6 MB/s eta 0:00:03\n",
|
124 |
+
" ------------------------ 39.2/63.8 MB 8.7 MB/s eta 0:00:03\n",
|
125 |
+
" ------------------------ 39.6/63.8 MB 8.8 MB/s eta 0:00:03\n",
|
126 |
+
" ------------------------- 40.1/63.8 MB 9.0 MB/s eta 0:00:03\n",
|
127 |
+
" ------------------------- 40.5/63.8 MB 9.2 MB/s eta 0:00:03\n",
|
128 |
+
" ------------------------- 41.0/63.8 MB 9.2 MB/s eta 0:00:03\n",
|
129 |
+
" ------------------------- 41.4/63.8 MB 9.4 MB/s eta 0:00:03\n",
|
130 |
+
" -------------------------- 41.7/63.8 MB 9.2 MB/s eta 0:00:03\n",
|
131 |
+
" -------------------------- 42.3/63.8 MB 9.6 MB/s eta 0:00:03\n",
|
132 |
+
" -------------------------- 42.8/63.8 MB 9.6 MB/s eta 0:00:03\n",
|
133 |
+
" --------------------------- 43.3/63.8 MB 9.6 MB/s eta 0:00:03\n",
|
134 |
+
" --------------------------- 43.6/63.8 MB 9.6 MB/s eta 0:00:03\n",
|
135 |
+
" --------------------------- 44.2/63.8 MB 9.8 MB/s eta 0:00:02\n",
|
136 |
+
" ---------------------------- 44.7/63.8 MB 9.8 MB/s eta 0:00:02\n",
|
137 |
+
" ---------------------------- 45.2/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
138 |
+
" ---------------------------- 45.6/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
139 |
+
" ---------------------------- 46.1/63.8 MB 9.8 MB/s eta 0:00:02\n",
|
140 |
+
" ----------------------------- 46.5/63.8 MB 9.8 MB/s eta 0:00:02\n",
|
141 |
+
" ----------------------------- 46.9/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
142 |
+
" ----------------------------- 47.4/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
143 |
+
" ----------------------------- 47.9/63.8 MB 10.1 MB/s eta 0:00:02\n",
|
144 |
+
" ----------------------------- 48.4/63.8 MB 10.1 MB/s eta 0:00:02\n",
|
145 |
+
" ------------------------------ 48.8/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
146 |
+
" ------------------------------ 49.4/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
147 |
+
" ------------------------------- 49.8/63.8 MB 9.8 MB/s eta 0:00:02\n",
|
148 |
+
" ------------------------------- 50.2/63.8 MB 9.8 MB/s eta 0:00:02\n",
|
149 |
+
" ------------------------------- 50.8/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
150 |
+
" -------------------------------- 51.2/63.8 MB 9.8 MB/s eta 0:00:02\n",
|
151 |
+
" -------------------------------- 51.5/63.8 MB 9.8 MB/s eta 0:00:02\n",
|
152 |
+
" -------------------------------- 52.0/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
153 |
+
" -------------------------------- 52.4/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
154 |
+
" --------------------------------- 52.9/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
155 |
+
" --------------------------------- 53.4/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
156 |
+
" --------------------------------- 53.8/63.8 MB 9.9 MB/s eta 0:00:02\n",
|
157 |
+
" ---------------------------------- 54.4/63.8 MB 9.9 MB/s eta 0:00:01\n",
|
158 |
+
" ---------------------------------- 54.7/63.8 MB 9.6 MB/s eta 0:00:01\n",
|
159 |
+
" ---------------------------------- 55.2/63.8 MB 9.8 MB/s eta 0:00:01\n",
|
160 |
+
" ---------------------------------- 55.5/63.8 MB 9.6 MB/s eta 0:00:01\n",
|
161 |
+
" ----------------------------------- 56.0/63.8 MB 9.6 MB/s eta 0:00:01\n",
|
162 |
+
" ----------------------------------- 56.4/63.8 MB 9.8 MB/s eta 0:00:01\n",
|
163 |
+
" ----------------------------------- 57.1/63.8 MB 9.9 MB/s eta 0:00:01\n",
|
164 |
+
" ----------------------------------- 57.7/63.8 MB 10.1 MB/s eta 0:00:01\n",
|
165 |
+
" ------------------------------------ 58.1/63.8 MB 9.9 MB/s eta 0:00:01\n",
|
166 |
+
" ------------------------------------ 58.6/63.8 MB 9.9 MB/s eta 0:00:01\n",
|
167 |
+
" ------------------------------------ 59.1/63.8 MB 10.1 MB/s eta 0:00:01\n",
|
168 |
+
" ------------------------------------ 59.7/63.8 MB 10.1 MB/s eta 0:00:01\n",
|
169 |
+
" ------------------------------------ 60.2/63.8 MB 10.1 MB/s eta 0:00:01\n",
|
170 |
+
" ------------------------------------- 60.8/63.8 MB 10.2 MB/s eta 0:00:01\n",
|
171 |
+
" ------------------------------------- 61.3/63.8 MB 10.2 MB/s eta 0:00:01\n",
|
172 |
+
" ------------------------------------- 61.9/63.8 MB 10.6 MB/s eta 0:00:01\n",
|
173 |
+
" ------------------------------------- 61.9/63.8 MB 10.6 MB/s eta 0:00:01\n",
|
174 |
+
" -------------------------------------- 62.3/63.8 MB 10.1 MB/s eta 0:00:01\n",
|
175 |
+
" -------------------------------------- 62.9/63.8 MB 10.2 MB/s eta 0:00:01\n",
|
176 |
+
" -------------------------------------- 63.2/63.8 MB 10.1 MB/s eta 0:00:01\n",
|
177 |
+
" --------------------------------------- 63.8/63.8 MB 9.9 MB/s eta 0:00:01\n",
|
178 |
+
" --------------------------------------- 63.8/63.8 MB 9.9 MB/s eta 0:00:01\n",
|
179 |
+
" --------------------------------------- 63.8/63.8 MB 9.9 MB/s eta 0:00:01\n",
|
180 |
+
" ---------------------------------------- 63.8/63.8 MB 8.8 MB/s eta 0:00:00\n",
|
181 |
+
" Installing build dependencies: started\n",
|
182 |
+
" Installing build dependencies: finished with status 'done'\n",
|
183 |
+
" Getting requirements to build wheel: started\n",
|
184 |
+
" Getting requirements to build wheel: finished with status 'done'\n",
|
185 |
+
" Preparing metadata (pyproject.toml): started\n",
|
186 |
+
" Preparing metadata (pyproject.toml): finished with status 'done'\n",
|
187 |
+
"Requirement already satisfied: typing-extensions>=4.5.0 in c:\\users\\bldng\\dev\\demo_human_gpt\\.venv\\lib\\site-packages (from llama-cpp-python) (4.12.2)\n",
|
188 |
+
"Requirement already satisfied: numpy>=1.20.0 in c:\\users\\bldng\\dev\\demo_human_gpt\\.venv\\lib\\site-packages (from llama-cpp-python) (2.1.1)\n",
|
189 |
+
"Collecting diskcache>=5.6.1 (from llama-cpp-python)\n",
|
190 |
+
" Downloading diskcache-5.6.3-py3-none-any.whl (45 kB)\n",
|
191 |
+
" 0.0/45.5 kB ? eta -:--:--\n",
|
192 |
+
" ---------------------------------------- 45.5/45.5 kB ? eta 0:00:00\n",
|
193 |
+
"Requirement already satisfied: jinja2>=2.11.3 in c:\\users\\bldng\\dev\\demo_human_gpt\\.venv\\lib\\site-packages (from llama-cpp-python) (3.1.4)\n",
|
194 |
+
"Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\bldng\\dev\\demo_human_gpt\\.venv\\lib\\site-packages (from jinja2>=2.11.3->llama-cpp-python) (2.1.5)\n",
|
195 |
+
"Building wheels for collected packages: llama-cpp-python\n",
|
196 |
+
" Building wheel for llama-cpp-python (pyproject.toml): started\n",
|
197 |
+
" Building wheel for llama-cpp-python (pyproject.toml): still running...\n",
|
198 |
+
" Building wheel for llama-cpp-python (pyproject.toml): finished with status 'done'\n",
|
199 |
+
" Created wheel for llama-cpp-python: filename=llama_cpp_python-0.2.90-cp311-cp311-win_amd64.whl size=3132437 sha256=b3123f77abab7606d9e29442b91118b19ce2419f505ffe71f599da6060482312\n",
|
200 |
+
" Stored in directory: c:\\users\\bldng\\appdata\\local\\pip\\cache\\wheels\\f8\\bd\\3d\\dcb25387572a6fe6c9c2953597c4c4d6dd985a425475da444d\n",
|
201 |
+
"Successfully built llama-cpp-python\n",
|
202 |
+
"Installing collected packages: diskcache, llama-cpp-python\n",
|
203 |
+
"Successfully installed diskcache-5.6.3 llama-cpp-python-0.2.90\n"
|
204 |
+
]
|
205 |
+
}
|
206 |
+
],
|
207 |
+
"source": [
|
208 |
+
"%pip install llama-cpp-python"
|
209 |
+
]
|
210 |
+
},
|
211 |
+
{
|
212 |
+
"cell_type": "code",
|
213 |
+
"execution_count": 27,
|
214 |
+
"metadata": {},
|
215 |
+
"outputs": [
|
216 |
+
{
|
217 |
+
"name": "stderr",
|
218 |
+
"output_type": "stream",
|
219 |
+
"text": [
|
220 |
+
"llama_model_loader: loaded meta data with 40 key-value pairs and 197 tensors from C:\\Users\\bldng\\.cache\\huggingface\\hub\\models--bartowski--Phi-3.5-mini-instruct-GGUF\\snapshots\\5c8d5381f90b6ca4348f090238be34eada23d192\\.\\Phi-3.5-mini-instruct-IQ3_XS.gguf (version GGUF V3 (latest))\n",
|
221 |
+
"llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.\n",
|
222 |
+
"llama_model_loader: - kv 0: general.architecture str = phi3\n",
|
223 |
+
"llama_model_loader: - kv 1: general.type str = model\n",
|
224 |
+
"llama_model_loader: - kv 2: general.name str = Phi 3.5 Mini Instruct\n",
|
225 |
+
"llama_model_loader: - kv 3: general.finetune str = instruct\n",
|
226 |
+
"llama_model_loader: - kv 4: general.basename str = Phi-3.5\n",
|
227 |
+
"llama_model_loader: - kv 5: general.size_label str = mini\n",
|
228 |
+
"llama_model_loader: - kv 6: general.license str = mit\n",
|
229 |
+
"llama_model_loader: - kv 7: general.license.link str = https://huggingface.co/microsoft/Phi-...\n",
|
230 |
+
"llama_model_loader: - kv 8: general.tags arr[str,3] = [\"nlp\", \"code\", \"text-generation\"]\n",
|
231 |
+
"llama_model_loader: - kv 9: general.languages arr[str,1] = [\"multilingual\"]\n",
|
232 |
+
"llama_model_loader: - kv 10: phi3.context_length u32 = 131072\n",
|
233 |
+
"llama_model_loader: - kv 11: phi3.rope.scaling.original_context_length u32 = 4096\n",
|
234 |
+
"llama_model_loader: - kv 12: phi3.embedding_length u32 = 3072\n",
|
235 |
+
"llama_model_loader: - kv 13: phi3.feed_forward_length u32 = 8192\n",
|
236 |
+
"llama_model_loader: - kv 14: phi3.block_count u32 = 32\n",
|
237 |
+
"llama_model_loader: - kv 15: phi3.attention.head_count u32 = 32\n",
|
238 |
+
"llama_model_loader: - kv 16: phi3.attention.head_count_kv u32 = 32\n",
|
239 |
+
"llama_model_loader: - kv 17: phi3.attention.layer_norm_rms_epsilon f32 = 0.000010\n",
|
240 |
+
"llama_model_loader: - kv 18: phi3.rope.dimension_count u32 = 96\n",
|
241 |
+
"llama_model_loader: - kv 19: phi3.rope.freq_base f32 = 10000.000000\n",
|
242 |
+
"llama_model_loader: - kv 20: general.file_type u32 = 22\n",
|
243 |
+
"llama_model_loader: - kv 21: phi3.attention.sliding_window u32 = 262144\n",
|
244 |
+
"llama_model_loader: - kv 22: phi3.rope.scaling.attn_factor f32 = 1.190238\n",
|
245 |
+
"llama_model_loader: - kv 23: tokenizer.ggml.model str = llama\n",
|
246 |
+
"llama_model_loader: - kv 24: tokenizer.ggml.pre str = default\n",
|
247 |
+
"llama_model_loader: - kv 25: tokenizer.ggml.tokens arr[str,32064] = [\"<unk>\", \"<s>\", \"</s>\", \"<0x00>\", \"<...\n",
|
248 |
+
"llama_model_loader: - kv 26: tokenizer.ggml.scores arr[f32,32064] = [-1000.000000, -1000.000000, -1000.00...\n",
|
249 |
+
"llama_model_loader: - kv 27: tokenizer.ggml.token_type arr[i32,32064] = [3, 3, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, ...\n",
|
250 |
+
"llama_model_loader: - kv 28: tokenizer.ggml.bos_token_id u32 = 1\n",
|
251 |
+
"llama_model_loader: - kv 29: tokenizer.ggml.eos_token_id u32 = 32000\n",
|
252 |
+
"llama_model_loader: - kv 30: tokenizer.ggml.unknown_token_id u32 = 0\n",
|
253 |
+
"llama_model_loader: - kv 31: tokenizer.ggml.padding_token_id u32 = 32000\n",
|
254 |
+
"llama_model_loader: - kv 32: tokenizer.ggml.add_bos_token bool = false\n",
|
255 |
+
"llama_model_loader: - kv 33: tokenizer.ggml.add_eos_token bool = false\n",
|
256 |
+
"llama_model_loader: - kv 34: tokenizer.chat_template str = {% for message in messages %}{% if me...\n",
|
257 |
+
"llama_model_loader: - kv 35: general.quantization_version u32 = 2\n",
|
258 |
+
"llama_model_loader: - kv 36: quantize.imatrix.file str = /models_out/Phi-3.5-mini-instruct-GGU...\n",
|
259 |
+
"llama_model_loader: - kv 37: quantize.imatrix.dataset str = /training_dir/calibration_datav3.txt\n",
|
260 |
+
"llama_model_loader: - kv 38: quantize.imatrix.entries_count i32 = 128\n",
|
261 |
+
"llama_model_loader: - kv 39: quantize.imatrix.chunks_count i32 = 151\n",
|
262 |
+
"llama_model_loader: - type f32: 67 tensors\n",
|
263 |
+
"llama_model_loader: - type q6_K: 1 tensors\n",
|
264 |
+
"llama_model_loader: - type iq3_xxs: 24 tensors\n",
|
265 |
+
"llama_model_loader: - type iq3_s: 105 tensors\n",
|
266 |
+
"llm_load_vocab: special tokens cache size = 14\n",
|
267 |
+
"llm_load_vocab: token to piece cache size = 0.1685 MB\n",
|
268 |
+
"llm_load_print_meta: format = GGUF V3 (latest)\n",
|
269 |
+
"llm_load_print_meta: arch = phi3\n",
|
270 |
+
"llm_load_print_meta: vocab type = SPM\n",
|
271 |
+
"llm_load_print_meta: n_vocab = 32064\n",
|
272 |
+
"llm_load_print_meta: n_merges = 0\n",
|
273 |
+
"llm_load_print_meta: vocab_only = 0\n",
|
274 |
+
"llm_load_print_meta: n_ctx_train = 131072\n",
|
275 |
+
"llm_load_print_meta: n_embd = 3072\n",
|
276 |
+
"llm_load_print_meta: n_layer = 32\n",
|
277 |
+
"llm_load_print_meta: n_head = 32\n",
|
278 |
+
"llm_load_print_meta: n_head_kv = 32\n",
|
279 |
+
"llm_load_print_meta: n_rot = 96\n",
|
280 |
+
"llm_load_print_meta: n_swa = 262144\n",
|
281 |
+
"llm_load_print_meta: n_embd_head_k = 96\n",
|
282 |
+
"llm_load_print_meta: n_embd_head_v = 96\n",
|
283 |
+
"llm_load_print_meta: n_gqa = 1\n",
|
284 |
+
"llm_load_print_meta: n_embd_k_gqa = 3072\n",
|
285 |
+
"llm_load_print_meta: n_embd_v_gqa = 3072\n",
|
286 |
+
"llm_load_print_meta: f_norm_eps = 0.0e+00\n",
|
287 |
+
"llm_load_print_meta: f_norm_rms_eps = 1.0e-05\n",
|
288 |
+
"llm_load_print_meta: f_clamp_kqv = 0.0e+00\n",
|
289 |
+
"llm_load_print_meta: f_max_alibi_bias = 0.0e+00\n",
|
290 |
+
"llm_load_print_meta: f_logit_scale = 0.0e+00\n",
|
291 |
+
"llm_load_print_meta: n_ff = 8192\n",
|
292 |
+
"llm_load_print_meta: n_expert = 0\n",
|
293 |
+
"llm_load_print_meta: n_expert_used = 0\n",
|
294 |
+
"llm_load_print_meta: causal attn = 1\n",
|
295 |
+
"llm_load_print_meta: pooling type = 0\n",
|
296 |
+
"llm_load_print_meta: rope type = 2\n",
|
297 |
+
"llm_load_print_meta: rope scaling = linear\n",
|
298 |
+
"llm_load_print_meta: freq_base_train = 10000.0\n",
|
299 |
+
"llm_load_print_meta: freq_scale_train = 1\n",
|
300 |
+
"llm_load_print_meta: n_ctx_orig_yarn = 4096\n",
|
301 |
+
"llm_load_print_meta: rope_finetuned = unknown\n",
|
302 |
+
"llm_load_print_meta: ssm_d_conv = 0\n",
|
303 |
+
"llm_load_print_meta: ssm_d_inner = 0\n",
|
304 |
+
"llm_load_print_meta: ssm_d_state = 0\n",
|
305 |
+
"llm_load_print_meta: ssm_dt_rank = 0\n",
|
306 |
+
"llm_load_print_meta: ssm_dt_b_c_rms = 0\n",
|
307 |
+
"llm_load_print_meta: model type = 3B\n",
|
308 |
+
"llm_load_print_meta: model ftype = IQ3_XS - 3.3 bpw\n",
|
309 |
+
"llm_load_print_meta: model params = 3.82 B\n",
|
310 |
+
"llm_load_print_meta: model size = 1.51 GiB (3.40 BPW) \n",
|
311 |
+
"llm_load_print_meta: general.name = Phi 3.5 Mini Instruct\n",
|
312 |
+
"llm_load_print_meta: BOS token = 1 '<s>'\n",
|
313 |
+
"llm_load_print_meta: EOS token = 32000 '<|endoftext|>'\n",
|
314 |
+
"llm_load_print_meta: UNK token = 0 '<unk>'\n",
|
315 |
+
"llm_load_print_meta: PAD token = 32000 '<|endoftext|>'\n",
|
316 |
+
"llm_load_print_meta: LF token = 13 '<0x0A>'\n",
|
317 |
+
"llm_load_print_meta: EOT token = 32007 '<|end|>'\n",
|
318 |
+
"llm_load_print_meta: max token length = 48\n",
|
319 |
+
"llm_load_tensors: ggml ctx size = 0.10 MiB\n",
|
320 |
+
"llm_load_tensors: CPU buffer size = 1549.18 MiB\n",
|
321 |
+
".......................................................................................\n",
|
322 |
+
"llama_new_context_with_model: n_ctx = 512\n",
|
323 |
+
"llama_new_context_with_model: n_batch = 512\n",
|
324 |
+
"llama_new_context_with_model: n_ubatch = 512\n",
|
325 |
+
"llama_new_context_with_model: flash_attn = 0\n",
|
326 |
+
"llama_new_context_with_model: freq_base = 10000.0\n",
|
327 |
+
"llama_new_context_with_model: freq_scale = 1\n",
|
328 |
+
"llama_kv_cache_init: CPU KV buffer size = 192.00 MiB\n",
|
329 |
+
"llama_new_context_with_model: KV self size = 192.00 MiB, K (f16): 96.00 MiB, V (f16): 96.00 MiB\n",
|
330 |
+
"llama_new_context_with_model: CPU output buffer size = 0.12 MiB\n",
|
331 |
+
"llama_new_context_with_model: CPU compute buffer size = 83.01 MiB\n",
|
332 |
+
"llama_new_context_with_model: graph nodes = 1286\n",
|
333 |
+
"llama_new_context_with_model: graph splits = 1\n",
|
334 |
+
"AVX = 1 | AVX_VNNI = 0 | AVX2 = 1 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | AVX512_BF16 = 0 | FMA = 1 | NEON = 0 | SVE = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | MATMUL_INT8 = 0 | LLAMAFILE = 1 | \n",
|
335 |
+
"Model metadata: {'general.name': 'Phi 3.5 Mini Instruct', 'general.architecture': 'phi3', 'general.type': 'model', 'general.basename': 'Phi-3.5', 'general.finetune': 'instruct', 'general.size_label': 'mini', 'general.license': 'mit', 'general.license.link': 'https://huggingface.co/microsoft/Phi-3.5-mini-instruct/resolve/main/LICENSE', 'phi3.attention.head_count_kv': '32', 'phi3.context_length': '131072', 'phi3.rope.scaling.original_context_length': '4096', 'phi3.embedding_length': '3072', 'tokenizer.ggml.model': 'llama', 'phi3.feed_forward_length': '8192', 'phi3.block_count': '32', 'phi3.attention.head_count': '32', 'phi3.attention.layer_norm_rms_epsilon': '0.000010', 'phi3.rope.dimension_count': '96', 'tokenizer.chat_template': \"{% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'<|system|>\\n' + message['content'] + '<|end|>\\n'}}{% elif message['role'] == 'user' %}{{'<|user|>\\n' + message['content'] + '<|end|>\\n'}}{% elif message['role'] == 'assistant' %}{{'<|assistant|>\\n' + message['content'] + '<|end|>\\n'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>\\n' }}{% else %}{{ eos_token }}{% endif %}\", 'phi3.rope.freq_base': '10000.000000', 'tokenizer.ggml.eos_token_id': '32000', 'general.file_type': '22', 'tokenizer.ggml.add_eos_token': 'false', 'phi3.attention.sliding_window': '262144', 'phi3.rope.scaling.attn_factor': '1.190238', 'tokenizer.ggml.pre': 'default', 'general.quantization_version': '2', 'tokenizer.ggml.bos_token_id': '1', 'tokenizer.ggml.unknown_token_id': '0', 'tokenizer.ggml.padding_token_id': '32000', 'tokenizer.ggml.add_bos_token': 'false', 'quantize.imatrix.chunks_count': '151', 'quantize.imatrix.file': '/models_out/Phi-3.5-mini-instruct-GGUF/Phi-3.5-mini-instruct.imatrix', 'quantize.imatrix.dataset': '/training_dir/calibration_datav3.txt', 'quantize.imatrix.entries_count': '128'}\n",
|
336 |
+
"Available chat formats from metadata: chat_template.default\n",
|
337 |
+
"Using gguf chat template: {% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'<|system|>\n",
|
338 |
+
"' + message['content'] + '<|end|>\n",
|
339 |
+
"'}}{% elif message['role'] == 'user' %}{{'<|user|>\n",
|
340 |
+
"' + message['content'] + '<|end|>\n",
|
341 |
+
"'}}{% elif message['role'] == 'assistant' %}{{'<|assistant|>\n",
|
342 |
+
"' + message['content'] + '<|end|>\n",
|
343 |
+
"'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>\n",
|
344 |
+
"' }}{% else %}{{ eos_token }}{% endif %}\n",
|
345 |
+
"Using chat eos_token: <|endoftext|>\n",
|
346 |
+
"Using chat bos_token: <s>\n"
|
347 |
+
]
|
348 |
+
}
|
349 |
+
],
|
350 |
+
"source": [
|
351 |
+
"from llama_cpp import Llama\n",
|
352 |
+
"\n",
|
353 |
+
"llm = Llama.from_pretrained(\n",
|
354 |
+
"\trepo_id=\"bartowski/Phi-3.5-mini-instruct-GGUF\",\n",
|
355 |
+
"\tfilename=\"Phi-3.5-mini-instruct-IQ3_XS.gguf\",\n",
|
356 |
+
")\n",
|
357 |
+
"\n"
|
358 |
+
]
|
359 |
+
},
|
360 |
+
{
|
361 |
+
"cell_type": "code",
|
362 |
+
"execution_count": 41,
|
363 |
+
"metadata": {},
|
364 |
+
"outputs": [
|
365 |
+
{
|
366 |
+
"name": "stdout",
|
367 |
+
"output_type": "stream",
|
368 |
+
"text": [
|
369 |
+
"Test 1\n"
|
370 |
+
]
|
371 |
+
},
|
372 |
+
{
|
373 |
+
"name": "stderr",
|
374 |
+
"output_type": "stream",
|
375 |
+
"text": [
|
376 |
+
"Llama.generate: 195 prefix-match hit, remaining 22 prompt tokens to eval\n",
|
377 |
+
"\n",
|
378 |
+
"llama_print_timings: load time = 1880.42 ms\n",
|
379 |
+
"llama_print_timings: sample time = 0.27 ms / 9 runs ( 0.03 ms per token, 33333.33 tokens per second)\n",
|
380 |
+
"llama_print_timings: prompt eval time = 1371.67 ms / 22 tokens ( 62.35 ms per token, 16.04 tokens per second)\n",
|
381 |
+
"llama_print_timings: eval time = 791.79 ms / 8 runs ( 98.97 ms per token, 10.10 tokens per second)\n",
|
382 |
+
"llama_print_timings: total time = 2166.71 ms / 30 tokens\n",
|
383 |
+
"Llama.generate: 196 prefix-match hit, remaining 26 prompt tokens to eval\n"
|
384 |
+
]
|
385 |
+
},
|
386 |
+
{
|
387 |
+
"name": "stdout",
|
388 |
+
"output_type": "stream",
|
389 |
+
"text": [
|
390 |
+
"<|user|>\n",
|
391 |
+
"What is the capital of France?<|end|>\n",
|
392 |
+
"<|assistant|>\n",
|
393 |
+
"The capital of France is Paris<|end|>\n",
|
394 |
+
"<|user|>\n",
|
395 |
+
" \n",
|
396 |
+
"<|end\n",
|
397 |
+
"Test 2\n"
|
398 |
+
]
|
399 |
+
},
|
400 |
+
{
|
401 |
+
"name": "stderr",
|
402 |
+
"output_type": "stream",
|
403 |
+
"text": [
|
404 |
+
"\n",
|
405 |
+
"llama_print_timings: load time = 1880.42 ms\n",
|
406 |
+
"llama_print_timings: sample time = 0.30 ms / 9 runs ( 0.03 ms per token, 29801.32 tokens per second)\n",
|
407 |
+
"llama_print_timings: prompt eval time = 1561.16 ms / 26 tokens ( 60.04 ms per token, 16.65 tokens per second)\n",
|
408 |
+
"llama_print_timings: eval time = 787.52 ms / 8 runs ( 98.44 ms per token, 10.16 tokens per second)\n",
|
409 |
+
"llama_print_timings: total time = 2352.22 ms / 34 tokens\n",
|
410 |
+
"Llama.generate: 195 prefix-match hit, remaining 23 prompt tokens to eval\n"
|
411 |
+
]
|
412 |
+
},
|
413 |
+
{
|
414 |
+
"name": "stdout",
|
415 |
+
"output_type": "stream",
|
416 |
+
"text": [
|
417 |
+
"<|user|>\n",
|
418 |
+
"What is 3*4?<|end|>\n",
|
419 |
+
"<|assistant|>\n",
|
420 |
+
"The result of 3*4 is 12<|end|>\n",
|
421 |
+
"<|user|>\n",
|
422 |
+
" \n",
|
423 |
+
"<|end\n",
|
424 |
+
"Test 3\n"
|
425 |
+
]
|
426 |
+
},
|
427 |
+
{
|
428 |
+
"name": "stderr",
|
429 |
+
"output_type": "stream",
|
430 |
+
"text": [
|
431 |
+
"\n",
|
432 |
+
"llama_print_timings: load time = 1880.42 ms\n",
|
433 |
+
"llama_print_timings: sample time = 0.21 ms / 7 runs ( 0.03 ms per token, 32863.85 tokens per second)\n",
|
434 |
+
"llama_print_timings: prompt eval time = 1388.34 ms / 23 tokens ( 60.36 ms per token, 16.57 tokens per second)\n",
|
435 |
+
"llama_print_timings: eval time = 578.12 ms / 6 runs ( 96.35 ms per token, 10.38 tokens per second)\n",
|
436 |
+
"llama_print_timings: total time = 1969.21 ms / 29 tokens\n"
|
437 |
+
]
|
438 |
+
},
|
439 |
+
{
|
440 |
+
"name": "stdout",
|
441 |
+
"output_type": "stream",
|
442 |
+
"text": [
|
443 |
+
"<|user|>\n",
|
444 |
+
"What it the capital?<|end|>\n",
|
445 |
+
"<|assistant|>\n",
|
446 |
+
"Please specify which country you are referring to.<|end|>\n",
|
447 |
+
"<|user|>\n",
|
448 |
+
" \n",
|
449 |
+
"The capital of Italy\n"
|
450 |
+
]
|
451 |
+
}
|
452 |
+
],
|
453 |
+
"source": [
|
454 |
+
"syspropmt=r\"\"\"\n",
|
455 |
+
"<|system|>\n",
|
456 |
+
"The User will make an inquiry to the assistant.\n",
|
457 |
+
"Fullfill the users inquiry.\n",
|
458 |
+
"The User will write a message with the content \"<|endtile|>\" if his inquiry is fullfilled.\n",
|
459 |
+
"The User will never have more than one inquiry in one conversation.\n",
|
460 |
+
"The User will never complete his own inquiry.\n",
|
461 |
+
"All conversations will end with \"<|endtile|>\".\n",
|
462 |
+
"After each User message is one assistant response.\n",
|
463 |
+
"There can never be more than one assistant response in succession.\n",
|
464 |
+
"The end of each user and assistant message is marked with \"<|end|>\".\n",
|
465 |
+
"\n",
|
466 |
+
"\n",
|
467 |
+
"Example:\n",
|
468 |
+
"<|user|>\n",
|
469 |
+
"What is the capital?<|end|>\n",
|
470 |
+
"<|assistant|>\n",
|
471 |
+
"Could you please specify which capital you are referring to?<|end|>\n",
|
472 |
+
"<|user|>\n",
|
473 |
+
"The capital of France<|end|>\n",
|
474 |
+
"<|assistant|>\n",
|
475 |
+
"The capital of France is Paris\n",
|
476 |
+
"<|user|>\n",
|
477 |
+
"<|endtile|><|end|>\n",
|
478 |
+
"\"\"\".strip()\n",
|
479 |
+
"tests=[\n",
|
480 |
+
"\"\"\"\n",
|
481 |
+
"<|user|>\n",
|
482 |
+
"What is the capital of France?<|end|>\n",
|
483 |
+
"<|assistant|>\n",
|
484 |
+
"The capital of France is Paris<|end|>\n",
|
485 |
+
"<|user|>\n",
|
486 |
+
"\"\"\".strip(),#Should terminate the conversation with <|endtile|>\n",
|
487 |
+
"\"\"\"\n",
|
488 |
+
"<|user|>\n",
|
489 |
+
"What is 3*4?<|end|>\n",
|
490 |
+
"<|assistant|>\n",
|
491 |
+
"The result of 3*4 is 12<|end|>\n",
|
492 |
+
"<|user|>\n",
|
493 |
+
"\"\"\".strip(),#Should terminate the conversation with <|endtile|>\n",
|
494 |
+
"\"\"\"\n",
|
495 |
+
"<|user|>\n",
|
496 |
+
"What it the capital?<|end|>\n",
|
497 |
+
"<|assistant|>\n",
|
498 |
+
"Please specify which country you are referring to.<|end|>\n",
|
499 |
+
"<|user|>\n",
|
500 |
+
"\"\"\".strip(),#Should specify the country\n",
|
501 |
+
"]\n",
|
502 |
+
"for num,test in enumerate(tests):\n",
|
503 |
+
" print(f\"Test {num+1}\")\n",
|
504 |
+
" output=llm(syspropmt+test, stop=[\"\\n \",\"?\\n\",\".\\n\",\"tile|>\"],max_tokens=100)[\"choices\"][0][\"text\"]#Only stop at tile|> to see if the conv got terminated\n",
|
505 |
+
" print(test)\n",
|
506 |
+
" print(output)"
|
507 |
+
]
|
508 |
+
}
|
509 |
+
],
|
510 |
+
"metadata": {
|
511 |
+
"kernelspec": {
|
512 |
+
"display_name": ".venv",
|
513 |
+
"language": "python",
|
514 |
+
"name": "python3"
|
515 |
+
},
|
516 |
+
"language_info": {
|
517 |
+
"codemirror_mode": {
|
518 |
+
"name": "ipython",
|
519 |
+
"version": 3
|
520 |
+
},
|
521 |
+
"file_extension": ".py",
|
522 |
+
"mimetype": "text/x-python",
|
523 |
+
"name": "python",
|
524 |
+
"nbconvert_exporter": "python",
|
525 |
+
"pygments_lexer": "ipython3",
|
526 |
+
"version": "3.11.4"
|
527 |
+
}
|
528 |
+
},
|
529 |
+
"nbformat": 4,
|
530 |
+
"nbformat_minor": 2
|
531 |
+
}
|
interactive_test.py
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from re import sub
|
2 |
+
from typing import Dict, List
|
3 |
+
import gradio as gr
|
4 |
+
from llama_cpp import Llama
|
5 |
+
import random
|
6 |
+
import time
|
7 |
+
|
8 |
+
from sympy import Li
|
9 |
+
|
10 |
+
syspropmt=r"""
|
11 |
+
<|system|>
|
12 |
+
The User will make an inquiry to the assistant.
|
13 |
+
Fullfill the users inquiry.
|
14 |
+
The User will write a message with the content "<|endtile|>" if his inquiry is fullfilled.
|
15 |
+
The User will never have more than one inquiry in one conversation.
|
16 |
+
The User will never complete his own inquiry.
|
17 |
+
All conversations will end with "<|endtile|>".
|
18 |
+
After each User message is one assistant response.
|
19 |
+
There can never be more than one assistant response in succession.
|
20 |
+
The end of each user and assistant message is marked with "<|end|>".
|
21 |
+
|
22 |
+
|
23 |
+
Example:
|
24 |
+
<|user|>
|
25 |
+
What is the capital?<|end|>
|
26 |
+
<|assistant|>
|
27 |
+
Could you please specify which capital you are referring to?<|end|>
|
28 |
+
<|user|>
|
29 |
+
The capital of France<|end|>
|
30 |
+
<|assistant|>
|
31 |
+
The capital of France is Paris
|
32 |
+
<|user|>
|
33 |
+
<|endtile|><|end|>
|
34 |
+
""".strip()
|
35 |
+
|
36 |
+
llm = Llama.from_pretrained(
|
37 |
+
repo_id="bartowski/Phi-3.5-mini-instruct-GGUF",
|
38 |
+
filename="Phi-3.5-mini-instruct-IQ3_XS.gguf",
|
39 |
+
n_gpu_layers=-1,
|
40 |
+
)
|
41 |
+
|
42 |
+
def chatmsg(message, role):
|
43 |
+
return {"role": role, "content": message}
|
44 |
+
|
45 |
+
|
46 |
+
def conv(msgs:List[Dict[str, str]]):
|
47 |
+
return "\n".join([f"<|{msg['role']}|>\n{msg['content']}<|end|>" for msg in msgs])
|
48 |
+
|
49 |
+
with gr.Blocks() as demo:
|
50 |
+
chatbot = gr.Chatbot([chatmsg("What is the capital?","user")],type="messages")
|
51 |
+
msg = gr.Textbox()
|
52 |
+
submit = gr.Button("Submit")
|
53 |
+
clear = gr.ClearButton([msg, chatbot])
|
54 |
+
|
55 |
+
def respond(message, chat_history:List[Dict[str, str]]):
|
56 |
+
if "End of conversation." in [i["content"] for i in chat_history]:
|
57 |
+
return "", chat_history
|
58 |
+
chat_history.append(chatmsg(message,"assistant"))
|
59 |
+
ret=llm(syspropmt+conv(chat_history)+"<|user|>\n", stop=["\n \n","?\n",".\n","tile|>"],max_tokens=100)#Only stop at tile|> to see if the conv got terminated
|
60 |
+
comp=ret["choices"][0]["text"]
|
61 |
+
print(repr(comp))
|
62 |
+
if("<|end" in comp):
|
63 |
+
chat_history.append(chatmsg("End of conversation.","user"))
|
64 |
+
else:
|
65 |
+
chat_history.append(chatmsg(comp,"user"))
|
66 |
+
return "", chat_history
|
67 |
+
|
68 |
+
submit.click(respond, [msg, chatbot], [msg, chatbot])
|
69 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
70 |
+
|
71 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
llama-cpp-python
|