Skip to content
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

a GGUF parser that works on remotely hosted files (over HTTP range requests) #540

Merged
merged 14 commits into from Mar 13, 2024
4 changes: 2 additions & 2 deletions .github/workflows/agents-publish.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
julien-c marked this conversation as resolved.
Show resolved Hide resolved
cache: "pnpm"
cache-dependency-path: |
packages/agents/pnpm-lock.yaml
Expand All @@ -59,7 +59,7 @@ jobs:
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/gguf-publish.yml
@@ -0,0 +1,63 @@
name: GGUF - Version and Release

on:
workflow_dispatch:
inputs:
newversion:
type: choice
description: "Semantic Version Bump Type"
default: patch
options:
- patch
- minor
- major

concurrency:
group: "push-to-main"

defaults:
run:
working-directory: packages/gguf

jobs:
version_and_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Needed to push the tag and the commit on the main branch, otherwise we get:
# > Run git push --follow-tags
# remote: error: GH006: Protected branch update failed for refs/heads/main.
# remote: error: Changes must be made through a pull request. Required status check "lint" is expected.
token: ${{ secrets.BOT_ACCESS_TOKEN }}
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "20"
cache: "pnpm"
cache-dependency-path: |
packages/gguf/pnpm-lock.yaml
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
registry-url: "https://registry.npmjs.org"
- run: pnpm install
- run: git config --global user.name machineuser
- run: git config --global user.email infra+machineuser@huggingface.co
- run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
# Update package.json with the new version
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
git commit . -m "🔖 @hugginface/gguf $BUMPED_VERSION"
git tag "gguf-v$BUMPED_VERSION"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git pull --rebase && git push --follow-tags
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/hub-publish.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"
cache-dependency-path: |
packages/hub/pnpm-lock.yaml
Expand All @@ -59,7 +59,7 @@ jobs:
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/inference-publish.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"
cache-dependency-path: |
packages/inference/pnpm-lock.yaml
Expand All @@ -59,7 +59,7 @@ jobs:
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/jinja-publish.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"
cache-dependency-path: |
packages/jinja/pnpm-lock.yaml
Expand All @@ -56,7 +56,7 @@ jobs:
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/languages-publish.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"
cache-dependency-path: |
packages/languages/pnpm-lock.yaml
Expand All @@ -56,7 +56,7 @@ jobs:
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Expand Up @@ -29,7 +29,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"
cache-dependency-path: "**/pnpm-lock.yaml"
- run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tasks-publish.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"
cache-dependency-path: |
packages/tasks/pnpm-lock.yaml
Expand All @@ -56,7 +56,7 @@ jobs:
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -29,7 +29,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"
cache-dependency-path: "**/pnpm-lock.yaml"
- run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/widgets-publish.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"
cache-dependency-path: |
packages/widgets/pnpm-lock.yaml
Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
Expand Down
4 changes: 4 additions & 0 deletions packages/gguf/.prettierignore
@@ -0,0 +1,4 @@
pnpm-lock.yaml
# In order to avoid code samples to have tabs, they don't display well on npm
README.md
dist
17 changes: 17 additions & 0 deletions packages/gguf/README.md
@@ -0,0 +1,17 @@
# `@huggingface/gguf`

A GGUF parser that works on remotely hosted files.

## Spec

https://github.com/ggerganov/ggml/blob/master/docs/gguf.md

Reference implementation (Python): https://github.com/ggerganov/llama.cpp/blob/master/gguf-py/gguf/gguf_reader.py

## Acknowledgements & Inspirations

- https://github.com/hyparam/hyllama by @platypii (MIT license)
- https://github.com/ahoylabs/gguf.js by @biw @dkogut1996 @spencekim (MIT license)

🔥❤️

51 changes: 51 additions & 0 deletions packages/gguf/package.json
@@ -0,0 +1,51 @@
{
"name": "@huggingface/gguf",
"packageManager": "pnpm@8.10.5",
"version": "0.0.1",
"description": "a GGUF parser that works on remotely hosted files",
"repository": "https://github.com/huggingface/huggingface.js.git",
"publishConfig": {
"access": "public"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
}
},
"browser": {
"./dist/index.js": "./dist/browser/index.js",
"./dist/index.mjs": "./dist/browser/index.mjs"
},
"engines": {
"node": ">=20"
},
"source": "index.ts",
"scripts": {
"lint": "eslint --quiet --fix --ext .cjs,.ts .",
"lint:check": "eslint --ext .cjs,.ts .",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepublishOnly": "pnpm run build",
"build": "tsup src/index.ts --format cjs,esm --clean --dts",
"test": "vitest run",
"check": "tsc"
},
"files": [
"dist",
"src",
"tsconfig.json"
],
"keywords": [
"huggingface",
"hub",
"gguf"
],
"author": "Hugging Face",
"license": "MIT",
"devDependencies": {}
}
1 change: 1 addition & 0 deletions packages/gguf/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.