-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @huggingface/ollama-utils
#1111
base: main
Are you sure you want to change the base?
Conversation
## Chat template converter | ||
|
||
```ts | ||
const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: complete this @ngxson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you feel up to it you can use tshy
instead, like in @hugginface/tasks
.
It has more accurate exports / better compatibility with all that includes the package (and as long as you don't have different code in browser/node it should be easy to configure)
btw the github action to publish should be added (with optionnally a check to check the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know enough typescript to review, but two questions/comments from myside:
- maybe in a follow-up PR we should add a scraper and something to update the mapping?
- via comments/ README/ docs we should clarify how users can add their own exception as well
With the ollama compatibility layer already been up and running on HF hub for a while now, we want to open-source part of the integration for (1) provide more transparency, and (2) for encouraging the community to contribute.
Therefore, we decided to publish
@huggingface/ollama-utils
, a package containing tools that power this integration.For now, the only tool that we provide is
chat-template.ts
, a tool that takes a parsed GGUF config from@huggingface/gguf
as input, then returns the ollama Go template.chat-template.ts
This module expose one single
convertGGUFTemplateToOllama
function. It works by trying (by order) these mechanisms:scripts/generate-automap.ts
RE_SPECIAL_TOKEN
CUSTOM_TEMPLATE_MAPPING
, a list of hand-picked template mapping@huggingface/jinja
. SeeconvertJinjaToGoTemplate