Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Speech To Speech
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
huggingface
Speech To Speech
Commits
e417e55c
Unverified
Commit
e417e55c
authored
6 months ago
by
Andrés Marafioti
Committed by
GitHub
6 months ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #40 from TrelisResearch/main
Allow LM selection and MLX Gemma
parents
cb48b916
3d98e34b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LLM/mlx_lm.py
+9
-3
9 additions, 3 deletions
LLM/mlx_lm.py
with
9 additions
and
3 deletions
LLM/mlx_lm.py
+
9
−
3
View file @
e417e55c
...
@@ -30,8 +30,7 @@ class MLXLanguageModelHandler(BaseHandler):
...
@@ -30,8 +30,7 @@ class MLXLanguageModelHandler(BaseHandler):
init_chat_prompt
=
"
You are a helpful AI assistant.
"
,
init_chat_prompt
=
"
You are a helpful AI assistant.
"
,
):
):
self
.
model_name
=
model_name
self
.
model_name
=
model_name
model_id
=
"
microsoft/Phi-3-mini-4k-instruct
"
self
.
model
,
self
.
tokenizer
=
load
(
self
.
model_name
)
self
.
model
,
self
.
tokenizer
=
load
(
model_id
)
self
.
gen_kwargs
=
gen_kwargs
self
.
gen_kwargs
=
gen_kwargs
self
.
chat
=
Chat
(
chat_size
)
self
.
chat
=
Chat
(
chat_size
)
...
@@ -67,8 +66,15 @@ class MLXLanguageModelHandler(BaseHandler):
...
@@ -67,8 +66,15 @@ class MLXLanguageModelHandler(BaseHandler):
logger
.
debug
(
"
infering language model...
"
)
logger
.
debug
(
"
infering language model...
"
)
self
.
chat
.
append
({
"
role
"
:
self
.
user_role
,
"
content
"
:
prompt
})
self
.
chat
.
append
({
"
role
"
:
self
.
user_role
,
"
content
"
:
prompt
})
# Remove system messages if using a Gemma model
if
"
gemma
"
in
self
.
model_name
.
lower
():
chat_messages
=
[
msg
for
msg
in
self
.
chat
.
to_list
()
if
msg
[
"
role
"
]
!=
"
system
"
]
else
:
chat_messages
=
self
.
chat
.
to_list
()
prompt
=
self
.
tokenizer
.
apply_chat_template
(
prompt
=
self
.
tokenizer
.
apply_chat_template
(
self
.
chat
.
to_list
()
,
tokenize
=
False
,
add_generation_prompt
=
True
chat_messages
,
tokenize
=
False
,
add_generation_prompt
=
True
)
)
output
=
""
output
=
""
curr_output
=
""
curr_output
=
""
...
...
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