AgainstEntropy commited on
Commit
c931afe
Β·
1 Parent(s): 0f49d49
.gitignore ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ tmp/
3
+
4
+ # Below are from https://github.com/github/gitignore/blob/main/Python.gitignore
5
+
6
+ # Byte-compiled / optimized / DLL files
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+
11
+ # C extensions
12
+ *.so
13
+
14
+ # Distribution / packaging
15
+ .Python
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ downloads/
20
+ eggs/
21
+ .eggs/
22
+ lib/
23
+ lib64/
24
+ parts/
25
+ sdist/
26
+ var/
27
+ wheels/
28
+ share/python-wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .nox/
48
+ .coverage
49
+ .coverage.*
50
+ .cache
51
+ nosetests.xml
52
+ coverage.xml
53
+ *.cover
54
+ *.py,cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+ cover/
58
+
59
+ # Translations
60
+ *.mo
61
+ *.pot
62
+
63
+ # Django stuff:
64
+ *.log
65
+ local_settings.py
66
+ db.sqlite3
67
+ db.sqlite3-journal
68
+
69
+ # Flask stuff:
70
+ instance/
71
+ .webassets-cache
72
+
73
+ # Scrapy stuff:
74
+ .scrapy
75
+
76
+ # Sphinx documentation
77
+ docs/_build/
78
+
79
+ # PyBuilder
80
+ .pybuilder/
81
+ target/
82
+
83
+ # Jupyter Notebook
84
+ .ipynb_checkpoints
85
+
86
+ # IPython
87
+ profile_default/
88
+ ipython_config.py
89
+
90
+ # pyenv
91
+ # For a library or package, you might want to ignore these files since the code is
92
+ # intended to run in multiple environments; otherwise, check them in:
93
+ # .python-version
94
+
95
+ # pipenv
96
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
98
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
99
+ # install all needed dependencies.
100
+ #Pipfile.lock
101
+
102
+ # poetry
103
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
104
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
105
+ # commonly ignored for libraries.
106
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
107
+ #poetry.lock
108
+
109
+ # pdm
110
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
111
+ #pdm.lock
112
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
113
+ # in version control.
114
+ # https://pdm.fming.dev/#use-with-ide
115
+ .pdm.toml
116
+
117
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
118
+ __pypackages__/
119
+
120
+ # Celery stuff
121
+ celerybeat-schedule
122
+ celerybeat.pid
123
+
124
+ # SageMath parsed files
125
+ *.sage.py
126
+
127
+ # Environments
128
+ .env
129
+ .venv
130
+ env/
131
+ venv/
132
+ ENV/
133
+ env.bak/
134
+ venv.bak/
135
+
136
+ # Spyder project settings
137
+ .spyderproject
138
+ .spyproject
139
+
140
+ # Rope project settings
141
+ .ropeproject
142
+
143
+ # mkdocs documentation
144
+ /site
145
+
146
+ # mypy
147
+ .mypy_cache/
148
+ .dmypy.json
149
+ dmypy.json
150
+
151
+ # Pyre type checker
152
+ .pyre/
153
+
154
+ # pytype static type analyzer
155
+ .pytype/
156
+
157
+ # Cython debug symbols
158
+ cython_debug/
159
+
160
+ # PyCharm
161
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
162
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
163
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
164
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
165
+ #.idea/
LICENSE.txt ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LLAMA 2 COMMUNITY LICENSE AGREEMENT
2
+ Llama 2 Version Release Date: July 18, 2023
3
+
4
+ "Agreement" means the terms and conditions for use, reproduction, distribution and
5
+ modification of the Llama Materials set forth herein.
6
+
7
+ "Documentation" means the specifications, manuals and documentation
8
+ accompanying Llama 2 distributed by Meta at ai.meta.com/resources/models-and-
9
+ libraries/llama-downloads/.
10
+
11
+ "Licensee" or "you" means you, or your employer or any other person or entity (if
12
+ you are entering into this Agreement on such person or entity's behalf), of the age
13
+ required under applicable laws, rules or regulations to provide legal consent and that
14
+ has legal authority to bind your employer or such other person or entity if you are
15
+ entering in this Agreement on their behalf.
16
+
17
+ "Llama 2" means the foundational large language models and software and
18
+ algorithms, including machine-learning model code, trained model weights,
19
+ inference-enabling code, training-enabling code, fine-tuning enabling code and other
20
+ elements of the foregoing distributed by Meta at ai.meta.com/resources/models-and-
21
+ libraries/llama-downloads/.
22
+
23
+ "Llama Materials" means, collectively, Meta's proprietary Llama 2 and
24
+ Documentation (and any portion thereof) made available under this Agreement.
25
+
26
+ "Meta" or "we" means Meta Platforms Ireland Limited (if you are located in or, if you
27
+ are an entity, your principal place of business is in the EEA or Switzerland) and Meta
28
+ Platforms, Inc. (if you are located outside of the EEA or Switzerland).
29
+
30
+ By clicking "I Accept" below or by using or distributing any portion or element of the
31
+ Llama Materials, you agree to be bound by this Agreement.
32
+
33
+ 1. License Rights and Redistribution.
34
+
35
+ a. Grant of Rights. You are granted a non-exclusive, worldwide, non-
36
+ transferable and royalty-free limited license under Meta's intellectual property or
37
+ other rights owned by Meta embodied in the Llama Materials to use, reproduce,
38
+ distribute, copy, create derivative works of, and make modifications to the Llama
39
+ Materials.
40
+
41
+ b. Redistribution and Use.
42
+
43
+ i. If you distribute or make the Llama Materials, or any derivative works
44
+ thereof, available to a third party, you shall provide a copy of this Agreement to such
45
+ third party.
46
+ ii. If you receive Llama Materials, or any derivative works thereof, from
47
+ a Licensee as part of an integrated end user product, then Section 2 of this
48
+ Agreement will not apply to you.
49
+
50
+ iii. You must retain in all copies of the Llama Materials that you
51
+ distribute the following attribution notice within a "Notice" text file distributed as a
52
+ part of such copies: "Llama 2 is licensed under the LLAMA 2 Community License,
53
+ Copyright (c) Meta Platforms, Inc. All Rights Reserved."
54
+
55
+ iv. Your use of the Llama Materials must comply with applicable laws
56
+ and regulations (including trade compliance laws and regulations) and adhere to the
57
+ Acceptable Use Policy for the Llama Materials (available at
58
+ https://ai.meta.com/llama/use-policy), which is hereby incorporated by reference into
59
+ this Agreement.
60
+
61
+ v. You will not use the Llama Materials or any output or results of the
62
+ Llama Materials to improve any other large language model (excluding Llama 2 or
63
+ derivative works thereof).
64
+
65
+ 2. Additional Commercial Terms. If, on the Llama 2 version release date, the
66
+ monthly active users of the products or services made available by or for Licensee,
67
+ or Licensee's affiliates, is greater than 700 million monthly active users in the
68
+ preceding calendar month, you must request a license from Meta, which Meta may
69
+ grant to you in its sole discretion, and you are not authorized to exercise any of the
70
+ rights under this Agreement unless or until Meta otherwise expressly grants you
71
+ such rights.
72
+
73
+ 3. Disclaimer of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE
74
+ LLAMA MATERIALS AND ANY OUTPUT AND RESULTS THEREFROM ARE
75
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
76
+ EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY
77
+ WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR
78
+ FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE
79
+ FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING
80
+ THE LLAMA MATERIALS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR
81
+ USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND RESULTS.
82
+
83
+ 4. Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE
84
+ LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT,
85
+ NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS
86
+ AGREEMENT, FOR ANY LOST PROFITS OR ANY INDIRECT, SPECIAL,
87
+ CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN
88
+ IF META OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF
89
+ ANY OF THE FOREGOING.
90
+
91
+ 5. Intellectual Property.
92
+
93
+ a. No trademark licenses are granted under this Agreement, and in
94
+ connection with the Llama Materials, neither Meta nor Licensee may use any name
95
+ or mark owned by or associated with the other or any of its affiliates, except as
96
+ required for reasonable and customary use in describing and redistributing the
97
+ Llama Materials.
98
+
99
+ b. Subject to Meta's ownership of Llama Materials and derivatives made by or
100
+ for Meta, with respect to any derivative works and modifications of the Llama
101
+ Materials that are made by you, as between you and Meta, you are and will be the
102
+ owner of such derivative works and modifications.
103
+
104
+ c. If you institute litigation or other proceedings against Meta or any entity
105
+ (including a cross-claim or counterclaim in a lawsuit) alleging that the Llama
106
+ Materials or Llama 2 outputs or results, or any portion of any of the foregoing,
107
+ constitutes infringement of intellectual property or other rights owned or licensable
108
+ by you, then any licenses granted to you under this Agreement shall terminate as of
109
+ the date such litigation or claim is filed or instituted. You will indemnify and hold
110
+ harmless Meta from and against any claim by any third party arising out of or related
111
+ to your use or distribution of the Llama Materials.
112
+
113
+ 6. Term and Termination. The term of this Agreement will commence upon your
114
+ acceptance of this Agreement or access to the Llama Materials and will continue in
115
+ full force and effect until terminated in accordance with the terms and conditions
116
+ herein. Meta may terminate this Agreement if you are in breach of any term or
117
+ condition of this Agreement. Upon termination of this Agreement, you shall delete
118
+ and cease use of the Llama Materials. Sections 3, 4 and 7 shall survive the
119
+ termination of this Agreement.
120
+
121
+ 7. Governing Law and Jurisdiction. This Agreement will be governed and
122
+ construed under the laws of the State of California without regard to choice of law
123
+ principles, and the UN Convention on Contracts for the International Sale of Goods
124
+ does not apply to this Agreement. The courts of California shall have exclusive
125
+ jurisdiction of any dispute arising out of this Agreement.
126
+
README.md CHANGED
@@ -1,13 +1,13 @@
1
  ---
2
  title: Kanji Streaming
3
- emoji: πŸ‰‘
4
- colorFrom: purple
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 4.19.2
8
- app_file: app.py
9
- pinned: false
10
- # suggested_hardware: a10g-small
11
  models:
12
  - mistralai/Mixtral-8x7B-Instruct-v0.1
13
  - runwayml/stable-diffusion-v1-5
@@ -16,4 +16,4 @@ models:
16
 
17
  ---
18
 
19
- Check out [original repo](https://github.com/AgainstEntropy/kanji) for mroe details!
 
1
  ---
2
  title: Kanji Streaming
3
+ emoji: πŸ‰‘ 🈢 🈚 🈺
4
+ colorFrom: yellow
5
+ colorTo: purple
6
  sdk: gradio
7
  sdk_version: 4.19.2
8
+ app_file: app-mixtral.py
9
+ pinned: true
10
+ suggested_hardware: a10g-small
11
  models:
12
  - mistralai/Mixtral-8x7B-Instruct-v0.1
13
  - runwayml/stable-diffusion-v1-5
 
16
 
17
  ---
18
 
19
+ Check out the [original repo](https://github.com/AgainstEntropy/kanji) for mroe details!
USE_POLICY.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Llama 2 Acceptable Use Policy
2
+
3
+ Meta is committed to promoting safe and fair use of its tools and features, including Llama 2. If you access or use Llama 2, you agree to this Acceptable Use Policy (β€œPolicy”). The most recent copy of this policy can be found at [ai.meta.com/llama/use-policy](http://ai.meta.com/llama/use-policy).
4
+
5
+ ## Prohibited Uses
6
+ We want everyone to use Llama 2 safely and responsibly. You agree you will not use, or allow others to use, Llama 2 to:
7
+
8
+ 1. Violate the law or others’ rights, including to:
9
+ 1. Engage in, promote, generate, contribute to, encourage, plan, incite, or further illegal or unlawful activity or content, such as:
10
+ 1. Violence or terrorism
11
+ 2. Exploitation or harm to children, including the solicitation, creation, acquisition, or dissemination of child exploitative content or failure to report Child Sexual Abuse Material
12
+ 3. Human trafficking, exploitation, and sexual violence
13
+ 4. The illegal distribution of information or materials to minors, including obscene materials, or failure to employ legally required age-gating in connection with such information or materials.
14
+ 5. Sexual solicitation
15
+ 6. Any other criminal activity
16
+ 2. Engage in, promote, incite, or facilitate the harassment, abuse, threatening, or bullying of individuals or groups of individuals
17
+ 3. Engage in, promote, incite, or facilitate discrimination or other unlawful or harmful conduct in the provision of employment, employment benefits, credit, housing, other economic benefits, or other essential goods and services
18
+ 4. Engage in the unauthorized or unlicensed practice of any profession including, but not limited to, financial, legal, medical/health, or related professional practices
19
+ 5. Collect, process, disclose, generate, or infer health, demographic, or other sensitive personal or private information about individuals without rights and consents required by applicable laws
20
+ 6. Engage in or facilitate any action or generate any content that infringes, misappropriates, or otherwise violates any third-party rights, including the outputs or results of any products or services using the Llama 2 Materials
21
+ 7. Create, generate, or facilitate the creation of malicious code, malware, computer viruses or do anything else that could disable, overburden, interfere with or impair the proper working, integrity, operation or appearance of a website or computer system
22
+
23
+
24
+
25
+ 2. Engage in, promote, incite, facilitate, or assist in the planning or development of activities that present a risk of death or bodily harm to individuals, including use of Llama 2 related to the following:
26
+ 1. Military, warfare, nuclear industries or applications, espionage, use for materials or activities that are subject to the International Traffic Arms Regulations (ITAR) maintained by the United States Department of State
27
+ 2. Guns and illegal weapons (including weapon development)
28
+ 3. Illegal drugs and regulated/controlled substances
29
+ 4. Operation of critical infrastructure, transportation technologies, or heavy machinery
30
+ 5. Self-harm or harm to others, including suicide, cutting, and eating disorders
31
+ 6. Any content intended to incite or promote violence, abuse, or any infliction of bodily harm to an individual
32
+
33
+
34
+
35
+ 3. Intentionally deceive or mislead others, including use of Llama 2 related to the following:
36
+ 1. Generating, promoting, or furthering fraud or the creation or promotion of disinformation
37
+ 2. Generating, promoting, or furthering defamatory content, including the creation of defamatory statements, images, or other content
38
+ 3. Generating, promoting, or further distributing spam
39
+ 4. Impersonating another individual without consent, authorization, or legal right
40
+ 5. Representing that the use of Llama 2 or outputs are human-generated
41
+ 6. Generating or facilitating false online engagement, including fake reviews and other means of fake online engagement
42
+ 4. Fail to appropriately disclose to end users any known dangers of your AI system
43
+
44
+ Please report any violation of this Policy, software β€œbug,” or other problems that could lead to a violation of this Policy through one of the following means:
45
+
46
+ * Reporting issues with the model: [github.com/facebookresearch/llama](http://github.com/facebookresearch/llama)
47
+ * Reporting risky content generated by the model: [developers.facebook.com/llama_output_feedback](http://developers.facebook.com/llama_output_feedback)
48
+ * Reporting bugs and security concerns: [facebook.com/whitehat/info](http://facebook.com/whitehat/info)
49
+ * Reporting violations of the Acceptable Use Policy or unlicensed uses of Llama: [[email protected]](mailto:[email protected])
50
+
app-kanji-local-llama.py ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import os
3
+ from queue import SimpleQueue
4
+ from threading import Thread
5
+ from typing import Iterator
6
+
7
+ import gradio as gr
8
+ import spaces
9
+ import torch
10
+ from gradio import Chatbot
11
+ from image_utils import ImageStitcher
12
+ from transformers import (AutoModelForCausalLM, AutoTokenizer,
13
+ TextIteratorStreamer)
14
+
15
+ from StreamDiffusionIO import LatentConsistencyModelStreamIO
16
+
17
+ MAX_MAX_NEW_TOKENS = 2048
18
+ DEFAULT_MAX_NEW_TOKENS = 1024
19
+ MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
20
+
21
+ DESCRIPTION = """\
22
+ # Kanji-Streaming Chat
23
+
24
+ 🌍 This Space is adapted from [Llama-2-7b-chat](https://huggingface.co/spaces/huggingface-projects/llama-2-7b-chat) space, demonstrating how to "chat" with LLM with [Kanji-Streaming](https://github.com/AgainstEntropy/kanji).
25
+
26
+ πŸ”¨ The technique behind Kanji-Streaming is [StreamDiffusionIO](https://github.com/AgainstEntropy/StreamDiffusionIO), which is based on [StreamDiffusion](https://github.com/cumulo-autumn/StreamDiffusion), *but especially allows to render text streams into image streams*.
27
+
28
+ πŸ”Ž For more details about Kanji-Streaming, take a look at the [github repository](https://github.com/AgainstEntropy/kanji).
29
+ """
30
+
31
+ LICENSE = """
32
+ <p/>
33
+
34
+ ---
35
+ As a derivate work of [Llama-2-7b-chat](https://huggingface.co/meta-llama/Llama-2-7b-chat) by Meta,
36
+ this demo is governed by the original [license](https://huggingface.co/spaces/huggingface-projects/llama-2-7b-chat/blob/main/LICENSE.txt) and [acceptable use policy](https://huggingface.co/spaces/huggingface-projects/llama-2-7b-chat/blob/main/USE_POLICY.md).
37
+ """
38
+
39
+
40
+ parser = argparse.ArgumentParser(description="Gradio launcher for Streaming-Kanji.")
41
+ parser.add_argument(
42
+ "--llama_model_id_or_path",
43
+ type=str,
44
+ default="meta-llama/Llama-2-7b-chat-hf",
45
+ required=False,
46
+ help="Path to downloaded llama-chat-hf model or model identifier from huggingface.co/models.",
47
+ )
48
+ parser.add_argument(
49
+ "--sd_model_id_or_path",
50
+ type=str,
51
+ default="runwayml/stable-diffusion-v1-5",
52
+ required=False,
53
+ help="Path to downloaded sd-1-5 model or model identifier from huggingface.co/models.",
54
+ )
55
+ parser.add_argument(
56
+ "--lora_path",
57
+ type=str,
58
+ default="AgainstEntropy/kanji-lora-sd-v1-5",
59
+ required=False,
60
+ help="Path to downloaded LoRA weight or model identifier from huggingface.co/models.",
61
+ )
62
+ parser.add_argument(
63
+ "--lcm_lora_path",
64
+ type=str,
65
+ default="AgainstEntropy/kanji-lcm-lora-sd-v1-5",
66
+ required=False,
67
+ help="Path to downloaded LCM-LoRA weight or model identifier from huggingface.co/models.",
68
+ )
69
+ parser.add_argument(
70
+ "--img_res",
71
+ type=int,
72
+ default=64,
73
+ required=False,
74
+ help="Image resolution for displaying Kanji characters in ChatBot.",
75
+ )
76
+ parser.add_argument(
77
+ "--img_per_line",
78
+ type=int,
79
+ default=16,
80
+ required=False,
81
+ help="Number of Kanji characters to display in a single line.",
82
+ )
83
+ parser.add_argument(
84
+ "--tmp_dir",
85
+ type=str,
86
+ default="./tmp",
87
+ required=False,
88
+ help="Path to save temporary images generated by StreamDiffusionIO.",
89
+ )
90
+
91
+ args = parser.parse_args()
92
+
93
+ if torch.cuda.is_available():
94
+ device = "cuda"
95
+ else:
96
+ device = "cpu"
97
+ DESCRIPTION += "\n<p>Running on CPU πŸ₯Ά This demo works best on GPU.</p>"
98
+
99
+ DESCRIPTION += "\n<p>This demo will get the best kanji streaming experience in localhost (or SSH forward), instead of shared link generated by Gradio.</p>"
100
+
101
+ model = AutoModelForCausalLM.from_pretrained(args.llama_model_id_or_path, torch_dtype=torch.float16, device_map="auto")
102
+ tokenizer = AutoTokenizer.from_pretrained(args.llama_model_id_or_path)
103
+ tokenizer.use_default_system_prompt = False
104
+ streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
105
+
106
+ lcm_stream = LatentConsistencyModelStreamIO(
107
+ model_id_or_path=args.sd_model_id_or_path,
108
+ lcm_lora_path=args.lcm_lora_path,
109
+ lora_dict={args.lora_path: 1},
110
+ resolution=128,
111
+ device=device,
112
+ use_xformers=True,
113
+ verbose=True,
114
+ )
115
+
116
+ tmp_dir_template = f"{args.tmp_dir}/%d"
117
+ response_num = 0
118
+
119
+ stitcher = ImageStitcher(
120
+ tmp_dir=tmp_dir_template % response_num,
121
+ img_res=args.img_res,
122
+ img_per_line=args.img_per_line,
123
+ verbose=True,
124
+ )
125
+
126
+
127
+ @spaces.GPU
128
+ def generate(
129
+ message: str,
130
+ chat_history: list[tuple[str, str]],
131
+ show_original_response: bool,
132
+ seed: int,
133
+ system_prompt: str = '',
134
+ max_new_tokens: int = 1024,
135
+ temperature: float = 0.6,
136
+ top_p: float = 0.9,
137
+ top_k: int = 50,
138
+ repetition_penalty: float = 1.2,
139
+ ) -> Iterator[str]:
140
+
141
+ conversation = []
142
+ if system_prompt:
143
+ conversation.append({"role": "system", "content": system_prompt})
144
+ for user, assistant in chat_history:
145
+ if isinstance(assistant, tuple):
146
+ assistant = assistant[1]
147
+ else:
148
+ assistant = str(assistant)
149
+ conversation.extend([
150
+ {"role": "user", "content": user},
151
+ {"role": "assistant", "content": assistant},
152
+ ])
153
+ conversation.append({"role": "user", "content": message})
154
+ print(conversation)
155
+
156
+ input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
157
+ if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
158
+ input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
159
+ gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
160
+ input_ids = input_ids.to(model.device)
161
+
162
+ generate_kwargs = dict(
163
+ {"input_ids": input_ids},
164
+ streamer=streamer,
165
+ max_new_tokens=max_new_tokens,
166
+ do_sample=True,
167
+ top_p=top_p,
168
+ top_k=top_k,
169
+ temperature=temperature,
170
+ num_beams=1,
171
+ repetition_penalty=repetition_penalty,
172
+ pad_token_id=tokenizer.eos_token_id
173
+ )
174
+ t = Thread(target=model.generate, kwargs=generate_kwargs)
175
+ t.start()
176
+
177
+ outputs = []
178
+ prompt_queue = SimpleQueue()
179
+
180
+ lcm_stream.reset(seed)
181
+ stitcher.reset()
182
+
183
+ global response_num
184
+ response_num += 1
185
+ stitcher.update_tmp_dir(tmp_dir_template % response_num)
186
+
187
+ def append_to_queue():
188
+ for text in streamer:
189
+ outputs.append(text)
190
+ prompt = text.strip()
191
+ if prompt:
192
+ if prompt.endswith("."): prompt = prompt[:-1]
193
+ prompt_queue.put(prompt)
194
+ prompt_queue.put(None)
195
+
196
+ append_thread = Thread(target=append_to_queue)
197
+ append_thread.start()
198
+
199
+ def show_image(prompt: str = None):
200
+ image, text = lcm_stream(prompt)
201
+ img_path = None
202
+ if image is not None:
203
+ img_path = stitcher.add(image, text)
204
+ return img_path
205
+
206
+ while True:
207
+ prompt = prompt_queue.get()
208
+ if prompt is None:
209
+ break
210
+ img_path = show_image(prompt)
211
+ if img_path is not None:
212
+ yield (img_path, )
213
+
214
+ # Continue to display the remaining images
215
+ while True:
216
+ img_path = show_image()
217
+ if img_path is not None:
218
+ yield (img_path, ''.join(outputs))
219
+ if lcm_stream.stop():
220
+ break
221
+
222
+ print(outputs)
223
+ if show_original_response:
224
+ yield ''.join(outputs)
225
+
226
+
227
+ chat_interface = gr.ChatInterface(
228
+ fn=generate,
229
+ chatbot=Chatbot(height=400),
230
+ additional_inputs=[
231
+ gr.Checkbox(
232
+ label="Show original response",
233
+ value=False,
234
+ ),
235
+ gr.Number(
236
+ label="Seed",
237
+ info="Random Seed for Kanji Generation (maybe some kind of accent πŸ€”)",
238
+ step=1,
239
+ value=1026,
240
+ ),
241
+ gr.Textbox(label="System prompt", lines=4),
242
+ gr.Slider(
243
+ label="Max new tokens",
244
+ minimum=1,
245
+ maximum=MAX_MAX_NEW_TOKENS,
246
+ step=1,
247
+ value=DEFAULT_MAX_NEW_TOKENS,
248
+ ),
249
+ gr.Slider(
250
+ label="Temperature",
251
+ minimum=0.1,
252
+ maximum=4.0,
253
+ step=0.1,
254
+ value=0.6,
255
+ ),
256
+ gr.Slider(
257
+ label="Top-p (nucleus sampling)",
258
+ minimum=0.05,
259
+ maximum=1.0,
260
+ step=0.05,
261
+ value=0.9,
262
+ ),
263
+ gr.Slider(
264
+ label="Top-k",
265
+ minimum=1,
266
+ maximum=1000,
267
+ step=1,
268
+ value=50,
269
+ ),
270
+ gr.Slider(
271
+ label="Repetition penalty",
272
+ minimum=1.0,
273
+ maximum=2.0,
274
+ step=0.05,
275
+ value=1.2,
276
+ ),
277
+ ],
278
+ stop_btn=None,
279
+ examples=[
280
+ ["Hello there! How are you doing?"],
281
+ ["Can you explain briefly to me what is the Python programming language?"],
282
+ ["Explain the plot of Cinderella in a sentence."],
283
+ ["How many hours does it take a man to eat a Helicopter?"],
284
+ ["Write a 100-word article on 'Benefits of Open-Source in AI research'"],
285
+ ],
286
+ )
287
+
288
+ with gr.Blocks(css="style.css") as demo:
289
+ gr.Markdown(DESCRIPTION)
290
+ gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
291
+ chat_interface.render()
292
+ gr.Markdown(LICENSE)
293
+
294
+ if __name__ == "__main__":
295
+ demo.queue(max_size=20).launch(server_name="0.0.0.0", share=False)
app-llama.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import os
3
+ from threading import Thread
4
+ from typing import Iterator
5
+
6
+ import gradio as gr
7
+ import spaces
8
+ import torch
9
+ from gradio import Chatbot
10
+ from transformers import (AutoModelForCausalLM, AutoTokenizer,
11
+ TextIteratorStreamer)
12
+
13
+ MAX_MAX_NEW_TOKENS = 2048
14
+ DEFAULT_MAX_NEW_TOKENS = 1024
15
+ MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
16
+
17
+ DESCRIPTION = """\
18
+ # Llama-2 7B Chat
19
+
20
+ This Space demonstrates model [Llama-2-7b-chat](https://huggingface.co/meta-llama/Llama-2-7b-chat) by Meta, a Llama 2 model with 7B parameters fine-tuned for chat instructions. Feel free to play with it, or duplicate to run generations without a queue! If you want to run your own service, you can also [deploy the model on Inference Endpoints](https://huggingface.co/inference-endpoints).
21
+
22
+ πŸ”Ž For more details about the Llama 2 family of models and how to use them with `transformers`, take a look [at our blog post](https://huggingface.co/blog/llama2).
23
+
24
+ πŸ”¨ Looking for an even more powerful model? Check out the [13B version](https://huggingface.co/spaces/huggingface-projects/llama-2-13b-chat) or the large [70B model demo](https://huggingface.co/spaces/ysharma/Explore_llamav2_with_TGI).
25
+ """
26
+
27
+ LICENSE = """
28
+ <p/>
29
+
30
+ ---
31
+ As a derivate work of [Llama-2-7b-chat](https://huggingface.co/meta-llama/Llama-2-7b-chat) by Meta,
32
+ this demo is governed by the original [license](https://huggingface.co/spaces/huggingface-projects/llama-2-7b-chat/blob/main/LICENSE.txt) and [acceptable use policy](https://huggingface.co/spaces/huggingface-projects/llama-2-7b-chat/blob/main/USE_POLICY.md).
33
+ """
34
+
35
+ parser = argparse.ArgumentParser(description="Gradio launcher for Streaming-Kanji.")
36
+ parser.add_argument(
37
+ "--llama_model_id_or_path",
38
+ type=str,
39
+ default="meta-llama/Llama-2-7b-chat-hf",
40
+ required=False,
41
+ help="Path to downloaded llama-chat-hf model or model identifier from huggingface.co/models.",
42
+ )
43
+ args = parser.parse_args()
44
+
45
+ if not torch.cuda.is_available():
46
+ DESCRIPTION += "\n<p>Running on CPU πŸ₯Ά This demo does not work on CPU.</p>"
47
+
48
+
49
+ if torch.cuda.is_available():
50
+ model_id = args.llama_model_id_or_path
51
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
52
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
53
+ tokenizer.use_default_system_prompt = False
54
+
55
+
56
+ @spaces.GPU
57
+ def generate(
58
+ message: str,
59
+ chat_history: list[tuple[str, str]],
60
+ system_prompt: str,
61
+ max_new_tokens: int = 1024,
62
+ temperature: float = 0.6,
63
+ top_p: float = 0.9,
64
+ top_k: int = 50,
65
+ repetition_penalty: float = 1.2,
66
+ ) -> Iterator[str]:
67
+ conversation = []
68
+ if system_prompt:
69
+ conversation.append({"role": "system", "content": system_prompt})
70
+ for user, assistant in chat_history:
71
+ conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
72
+ conversation.append({"role": "user", "content": message})
73
+
74
+ input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
75
+ if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
76
+ input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
77
+ gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
78
+ input_ids = input_ids.to(model.device)
79
+
80
+ streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
81
+ generate_kwargs = dict(
82
+ {"input_ids": input_ids},
83
+ streamer=streamer,
84
+ max_new_tokens=max_new_tokens,
85
+ do_sample=True,
86
+ top_p=top_p,
87
+ top_k=top_k,
88
+ temperature=temperature,
89
+ num_beams=1,
90
+ repetition_penalty=repetition_penalty,
91
+ )
92
+ t = Thread(target=model.generate, kwargs=generate_kwargs)
93
+ t.start()
94
+
95
+ outputs = []
96
+ for text in streamer:
97
+ outputs.append(text)
98
+ yield "".join(outputs)
99
+
100
+
101
+ chat_interface = gr.ChatInterface(
102
+ fn=generate,
103
+ chatbot=Chatbot(height=400),
104
+ additional_inputs=[
105
+ gr.Textbox(label="System prompt", lines=6),
106
+ gr.Slider(
107
+ label="Max new tokens",
108
+ minimum=1,
109
+ maximum=MAX_MAX_NEW_TOKENS,
110
+ step=1,
111
+ value=DEFAULT_MAX_NEW_TOKENS,
112
+ ),
113
+ gr.Slider(
114
+ label="Temperature",
115
+ minimum=0.1,
116
+ maximum=4.0,
117
+ step=0.1,
118
+ value=0.6,
119
+ ),
120
+ gr.Slider(
121
+ label="Top-p (nucleus sampling)",
122
+ minimum=0.05,
123
+ maximum=1.0,
124
+ step=0.05,
125
+ value=0.9,
126
+ ),
127
+ gr.Slider(
128
+ label="Top-k",
129
+ minimum=1,
130
+ maximum=1000,
131
+ step=1,
132
+ value=50,
133
+ ),
134
+ gr.Slider(
135
+ label="Repetition penalty",
136
+ minimum=1.0,
137
+ maximum=2.0,
138
+ step=0.05,
139
+ value=1.2,
140
+ ),
141
+ ],
142
+ stop_btn=None,
143
+ examples=[
144
+ ["Hello there! How are you doing?"],
145
+ ["Can you explain briefly to me what is the Python programming language?"],
146
+ ["Explain the plot of Cinderella in a sentence."],
147
+ ["How many hours does it take a man to eat a Helicopter?"],
148
+ ["Write a 100-word article on 'Benefits of Open-Source in AI research'"],
149
+ ],
150
+ )
151
+
152
+ with gr.Blocks(css="style.css") as demo:
153
+ gr.Markdown(DESCRIPTION)
154
+ gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
155
+ chat_interface.render()
156
+ gr.Markdown(LICENSE)
157
+
158
+ if __name__ == "__main__":
159
+ demo.queue(max_size=20).launch(server_name="0.0.0.0", share=False)
app.py β†’ app-mixtral.py RENAMED
@@ -88,17 +88,19 @@ else:
88
  device = "cpu"
89
  DESCRIPTION += "\n<p>Running on CPU πŸ₯Ά This demo works best on GPU.</p>"
90
 
91
- DESCRIPTION += "\n<p>This demo will get the best kanji streaming experience in localhost (or SSH forward), instead of shared link generated by Gradio.</p>"
92
-
93
  client = InferenceClient(
94
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
95
  )
96
 
97
- def format_prompt(message, history):
98
- prompt = "<s>"
99
  for user_prompt, bot_response in history:
100
  prompt += f"[INST] {user_prompt} [/INST]"
101
- prompt += f" {bot_response}</s> "
 
 
 
 
102
  prompt += f"[INST] {message} [/INST]"
103
  return prompt
104
 
@@ -114,7 +116,6 @@ lcm_stream = LatentConsistencyModelStreamIO(
114
 
115
  tmp_dir_template = f"{args.tmp_dir}/%d"
116
  response_num = 0
117
- response_cache = ""
118
 
119
  stitcher = ImageStitcher(
120
  tmp_dir=tmp_dir_template % response_num,
@@ -128,8 +129,9 @@ stitcher = ImageStitcher(
128
  def generate(
129
  message: str,
130
  chat_history: list[tuple[str, str]],
 
131
  seed: int,
132
- system_prompt: str,
133
  max_new_tokens: int = 1024,
134
  temperature: float = 0.6,
135
  top_p: float = 0.9,
@@ -140,8 +142,6 @@ def generate(
140
  if temperature < 1e-2:
141
  temperature = 1e-2
142
 
143
- global response_cache
144
-
145
  generate_kwargs = dict(
146
  max_new_tokens=max_new_tokens,
147
  do_sample=True,
@@ -150,11 +150,11 @@ def generate(
150
  temperature=temperature,
151
  repetition_penalty=repetition_penalty,
152
  )
153
- formatted_prompt = format_prompt(f"{system_prompt}, {message}", chat_history)
154
- stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
 
155
 
156
- global outputs
157
- outputs = ""
158
  prompt_queue = SimpleQueue()
159
 
160
  lcm_stream.reset(seed)
@@ -165,14 +165,13 @@ def generate(
165
  stitcher.update_tmp_dir(tmp_dir_template % response_num)
166
 
167
  def append_to_queue():
168
- for response in stream:
169
  text = response.token.text
170
- global outputs
171
- outputs += text
172
- text = text.strip()
173
- if text and text not in ['</s>']:
174
- if text.endswith("."): text = text[:-1]
175
- prompt_queue.put(text)
176
  prompt_queue.put(None)
177
 
178
  append_thread = Thread(target=append_to_queue)
@@ -197,26 +196,33 @@ def generate(
197
  while True:
198
  img_path = show_image()
199
  if img_path is not None:
200
- yield (img_path, )
201
  if lcm_stream.stop():
202
  break
203
 
204
- response_cache = outputs
205
  print(outputs)
206
- return outputs
 
207
 
208
 
209
  chat_interface = gr.ChatInterface(
210
  fn=generate,
211
  chatbot=Chatbot(height=400),
212
  additional_inputs=[
 
 
 
 
213
  gr.Number(
214
  label="Seed",
215
  info="Random Seed for Kanji Generation (maybe some kind of accent πŸ€”)",
216
  step=1,
217
  value=1026,
218
  ),
219
- gr.Textbox(label="System prompt", lines=4),
 
 
 
220
  gr.Slider(
221
  label="Max new tokens",
222
  minimum=1,
@@ -270,5 +276,4 @@ with gr.Blocks(css="style.css") as demo:
270
  gr.Markdown(LICENSE)
271
 
272
  if __name__ == "__main__":
273
- # demo.queue(max_size=20).launch(show_api=False)
274
- demo.queue(max_size=20).launch(server_name="0.0.0.0", share=False)
 
88
  device = "cpu"
89
  DESCRIPTION += "\n<p>Running on CPU πŸ₯Ά This demo works best on GPU.</p>"
90
 
 
 
91
  client = InferenceClient(
92
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
93
  )
94
 
95
+ def format_prompt(message, history, system_prompt=''):
96
+ prompt = f"<s> {system_prompt}"
97
  for user_prompt, bot_response in history:
98
  prompt += f"[INST] {user_prompt} [/INST]"
99
+ if isinstance(bot_response, tuple):
100
+ bot_response = bot_response[1]
101
+ if not bot_response.endswith("</s>"):
102
+ bot_response += "</s>"
103
+ prompt += f" {bot_response} "
104
  prompt += f"[INST] {message} [/INST]"
105
  return prompt
106
 
 
116
 
117
  tmp_dir_template = f"{args.tmp_dir}/%d"
118
  response_num = 0
 
119
 
120
  stitcher = ImageStitcher(
121
  tmp_dir=tmp_dir_template % response_num,
 
129
  def generate(
130
  message: str,
131
  chat_history: list[tuple[str, str]],
132
+ show_original_response: bool,
133
  seed: int,
134
+ system_prompt: str = '',
135
  max_new_tokens: int = 1024,
136
  temperature: float = 0.6,
137
  top_p: float = 0.9,
 
142
  if temperature < 1e-2:
143
  temperature = 1e-2
144
 
 
 
145
  generate_kwargs = dict(
146
  max_new_tokens=max_new_tokens,
147
  do_sample=True,
 
150
  temperature=temperature,
151
  repetition_penalty=repetition_penalty,
152
  )
153
+ formatted_prompt = format_prompt(message, chat_history, system_prompt)
154
+ print(formatted_prompt)
155
+ streamer = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
156
 
157
+ outputs = []
 
158
  prompt_queue = SimpleQueue()
159
 
160
  lcm_stream.reset(seed)
 
165
  stitcher.update_tmp_dir(tmp_dir_template % response_num)
166
 
167
  def append_to_queue():
168
+ for response in streamer:
169
  text = response.token.text
170
+ outputs.append(text)
171
+ prompt = text.strip()
172
+ if prompt and prompt not in ['</s>']:
173
+ if prompt.endswith("."): prompt = prompt[:-1]
174
+ prompt_queue.put(prompt)
 
175
  prompt_queue.put(None)
176
 
177
  append_thread = Thread(target=append_to_queue)
 
196
  while True:
197
  img_path = show_image()
198
  if img_path is not None:
199
+ yield (img_path, ''.join(outputs))
200
  if lcm_stream.stop():
201
  break
202
 
 
203
  print(outputs)
204
+ if show_original_response:
205
+ yield ''.join(outputs)
206
 
207
 
208
  chat_interface = gr.ChatInterface(
209
  fn=generate,
210
  chatbot=Chatbot(height=400),
211
  additional_inputs=[
212
+ gr.Checkbox(
213
+ label="Show original response",
214
+ value=False,
215
+ ),
216
  gr.Number(
217
  label="Seed",
218
  info="Random Seed for Kanji Generation (maybe some kind of accent πŸ€”)",
219
  step=1,
220
  value=1026,
221
  ),
222
+ gr.Textbox(
223
+ label="System prompt",
224
+ value="",
225
+ lines=4),
226
  gr.Slider(
227
  label="Max new tokens",
228
  minimum=1,
 
276
  gr.Markdown(LICENSE)
277
 
278
  if __name__ == "__main__":
279
+ demo.queue(max_size=20).launch(server_name="0.0.0.0", share=False, show_api=False)
 
run-app-mixtral.sh ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ source $VAST/miniconda3/bin/activate kanji
4
+
5
+ python app-mixtral.py \
6
+ --sd_model_id_or_path="$VAST/models/stable-diffusion-v1-5" \
7
+ --lora_path="$VAST/codes/kanji/lora_weights/kanji-lora-sd-v1-5" \
8
+ --lcm_lora_path="$VAST/codes/kanji/lora_weights/kanji-lcm-lora-sd-v1-5" \
9
+ --tmp_dir="./tmp"
run-kanji-local_llama.sh ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ source $VAST/miniconda3/bin/activate kanji
4
+
5
+ python app-kanji-local-llama.py \
6
+ --llama_model_id_or_path="$VAST/models/meta-llama/llama-2-7b-chat-hf" \
7
+ --sd_model_id_or_path="$VAST/models/stable-diffusion-v1-5" \
8
+ --lora_path="$VAST/codes/kanji/lora_weights/kanji-lora-sd-v1-5" \
9
+ --lcm_lora_path="$VAST/codes/kanji/lora_weights/kanji-lcm-lora-sd-v1-5" \
10
+ --tmp_dir="./tmp"
run-llama.sh ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ source $VAST/miniconda3/bin/activate kanji
4
+
5
+ python app-llama.py \
6
+ --llama_model_id_or_path="$VAST/models/meta-llama/llama-2-7b-chat-hf"