Skip to content

Commit

Permalink
rename to ollama-create
Browse files Browse the repository at this point in the history
omit tokens from parsed metadata
harmonize CLI options with Ollama
support disabling of layers
add --force, --dir & --help
improve log output
fix leaking file handles
use JavaScript Standard Style
basically rewrite the entire thing :)
  • Loading branch information
GenericMale committed Sep 6, 2024
1 parent aa7e91f commit 48fe32a
Show file tree
Hide file tree
Showing 6 changed files with 524 additions and 321 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
package-lock.json

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
Expand Down
22 changes: 11 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- omit in toc -->
# Contributing to Ollama Model Generator
# Contributing to Ollama Create NodeJS

First off, thanks for taking the time to contribute! ❤️

Expand Down Expand Up @@ -28,23 +28,23 @@ community looks forward to your contributions. 🎉
## Code of Conduct

This project and everyone participating in it is governed by the
[Code of Conduct](https://github.com/GenericMale/ollama-model-generator/blob/master/CODE_OF_CONDUCT.md).
[Code of Conduct](https://github.com/GenericMale/ollama-create-nodejs/blob/master/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable behavior
to .

## I Have a Question

> If you want to ask a question, we assume that you have read the
> available [Documentation](https://github.com/GenericMale/ollama-model-generator/blob/main/README.md).
> available [Documentation](https://github.com/GenericMale/ollama-create-nodejs/blob/main/README.md).
Before you ask a question, it is best to search for
existing [Issues](https://github.com/GenericMale/ollama-model-generator/issues) that might help you. In case you have found a
existing [Issues](https://github.com/GenericMale/ollama-create-nodejs/issues) that might help you. In case you have found a
suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search
the internet for answers first.

If you then still feel the need to ask a question and need clarification, we recommend the following:

- Open an [Issue](https://github.com/GenericMale/ollama-model-generator/issues/new).
- Open an [Issue](https://github.com/GenericMale/ollama-create-nodejs/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.

Expand All @@ -70,11 +70,11 @@ following steps in advance to help us fix any potential bug as fast as possible.
- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment
components/versions (Make sure that you have read
the [documentation](https://github.com/GenericMale/ollama-model-generator/blob/main/README.md). If you are looking for
the [documentation](https://github.com/GenericMale/ollama-create-nodejs/blob/main/README.md). If you are looking for
support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there
is not already a bug report existing for your bug or error in
the [bug tracker](https://github.com/GenericMale/ollama-model-generator/issues?q=label%3Abug).
the [bug tracker](https://github.com/GenericMale/ollama-create-nodejs/issues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside the GitHub community have
discussed the issue.
- Collect information about the bug:
Expand All @@ -92,7 +92,7 @@ following steps in advance to help us fix any potential bug as fast as possible.
We use GitHub issues to track bugs and errors. If you run into an issue with the project:

- Open an [Issue](https://github.com/GenericMale/ollama-model-generator/issues/new). (Since we can't be sure at this point
- Open an [Issue](https://github.com/GenericMale/ollama-create-nodejs/issues/new). (Since we can't be sure at this point
whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to
Expand All @@ -119,9 +119,9 @@ the community to understand your suggestion and find related suggestions.
#### Before Submitting an Enhancement

- Make sure that you are using the latest version.
- Read the [documentation](https://github.com/GenericMale/ollama-model-generator/blob/main/README.md) carefully and find out
- Read the [documentation](https://github.com/GenericMale/ollama-create-nodejs/blob/main/README.md) carefully and find out
if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/GenericMale/ollama-model-generator/issues) to see if the enhancement has already been
- Perform a [search](https://github.com/GenericMale/ollama-create-nodejs/issues) to see if the enhancement has already been
suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to
convince the project's developers of the merits of this feature. Keep in mind that we want features that will be
Expand All @@ -131,7 +131,7 @@ the community to understand your suggestion and find related suggestions.
<!-- omit in toc -->
#### How Do I Submit a Good Enhancement Suggestion?

Enhancement suggestions are tracked as [GitHub issues](https://github.com/GenericMale/ollama-model-generator/issues).
Enhancement suggestions are tracked as [GitHub issues](https://github.com/GenericMale/ollama-create-nodejs/issues).

- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
Expand Down
105 changes: 63 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Ollama Model Generator
# Ollama Create NodeJS

[![GitHub License](https://img.shields.io/github/license/GenericMale/ollama-model-generator?logo=github)](https://github.com/GenericMale/ollama-model-generator/blob/main/LICENSE)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/genericmale/ollama-model-generator?label=commit&logo=github)](https://github.com/GenericMale/ollama-model-generator)
[![NPM Package Version](https://img.shields.io/npm/v/ollama-model-generator?logo=npm&logoColor=white)](https://www.npmjs.com/package/ollama-model-generator)
[![NPM Package Size](https://img.shields.io/npm/unpacked-size/ollama-model-generator?label=size&logo=npm&logoColor=white)](https://www.npmjs.com/package/ollama-model-generator)
[![NodeJS Version](https://img.shields.io/node/v/ollama-model-generator?logo=node.js&logoColor=white)](https://www.npmjs.com/package/ollama-model-generator)
[![GitHub License](https://img.shields.io/github/license/GenericMale/ollama-create-nodejs?logo=github)](https://github.com/GenericMale/ollama-create-nodejs/blob/main/LICENSE)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/genericmale/ollama-create-nodejs?label=commit&logo=github)](https://github.com/GenericMale/ollama-create-nodejs)
[![NPM Package Version](https://img.shields.io/npm/v/ollama-create?logo=npm&logoColor=white)](https://www.npmjs.com/package/ollama-create)
[![NPM Package Size](https://img.shields.io/npm/unpacked-size/ollama-create?label=size&logo=npm&logoColor=white)](https://www.npmjs.com/package/ollama-create)
[![NodeJS Version](https://img.shields.io/node/v/ollama-create?logo=node.js&logoColor=white)](https://www.npmjs.com/package/ollama-create)

## Introduction

This NodeJS CLI script simplifies adding GGUF models to Ollama by creating symlinks and downloading necessary metadata
NodeJS CLI script which simplifies adding GGUF models to Ollama by creating symlinks and downloading necessary metadata
from the Ollama Registry.

Benefits:
Expand All @@ -22,73 +22,94 @@ Benefits:
Requires NodeJS version 18.11.0 or higher. Install it globally using npm:

```shell
npm install -g ollama-model-generator
npm install -g ollama-create
```

## Usage

```
ollama-model-generator [options]
Options:
--model <path> Path to the GGUF model file. This will be symlinked to Ollama blob storage.
If the file doesn't exist, it will be downloaded from the Ollama Registry based on --from.
Optional. If not provided, the model will be downloaded to the Ollama blob storage.
--from, -f <name> Model name in the Ollama Registry to download as a base.
Default: architecture of the GGUF model.
--name, -n <name> Name of the new model in Ollama.
Default: basename-size-finetune-version of the GGUF model.
If --model is not provided, it defaults to the name from --from.
--show, -s Prints model metadata from the GGUF file header as JSON (requires --model).
--registry, -r <registry> The Ollama Registry URL.
Default: registry.ollama.ai
--dir, -d <path> Directory for storing Ollama model data.
Default: $OLLAMA_MODELS or ~/.ollama/models
```

Additional files can be symlinked in the same way as --model (
see [Ollama Model File](https://github.com/ollama/ollama/blob/main/docs/modelfile.md)):

```
--adapter, --embed, --license, --messages, --params, --projector, --prompt, --system, --template
Usage: ollama-create [OPTIONS] [MODEL...]
Create a new Ollama model based on a base model from the Ollama registry.
MODEL can be a local GGUF file or the name of a model in the Ollama registry.
All specified files will be symlinked to Ollama to avoid duplication.
If a file is supplied which doesn't exist, it will be created from the base model in the specified location.
To remove a setting from the base model, use --no-<option>.
OPTIONS:
-f, --from <from> Defines the base model from the Ollama registry to use.
Defaults to the model architecture from the GGUF metadata.
-n, --name <name> Set the name for the new model.
Defaults to <name>-<size>-<finetune>-<version> from the GGUF metadata
or the base model name if no model file is specified.
-d, --dir <dir> Download all base model files to the specified directory and create symlinks for Ollama.
-p, --params <json file> Specify a JSON file containing parameters for Ollama.
-m, --messages <json file> Provide a JSON file containing the message history.
-t, --template <txt file> Define a file containing the full prompt template.
-s, --system <txt file> Specify a file containing the system message.
-a, --adapter <gguf file> Apply (Q)LoRA adapters to the model.
-j, --projector <gguf file> Define multimodal projectors.
-l, --license <txt file> Specify a file containing the legal license.
-g, --show Print the GGUF metadata of the model.
-h, --help Display this help and exit.
```

## Example

### Download a model from the Ollama Registry

```shell
ollama-model-generator --from gemma2
ollama-create gemma2
```

This will download the Gemma 2 model from the Ollama Registry and configure it in Ollama (same as `ollama pull gemma2`).

### Use a local GGUF model
### Use existing GGUF model file

```shell
ollama-model-generator --from llama3.1 --model my-model.gguf --name LLama3.1-MyModel
ollama-create --from llama3.1 my-model.gguf
```

This will use the local `my-model.gguf` file and configure it in Ollama with the name `LLama3.1-MyModel`.
This will use the local `my-model.gguf` file and configure it in Ollama by creating a symlink.
The Ollama metadata (template, params etc.) is taken from the Llama 3.1 model.

If `my-model.gguf` doesn't exist, the `llama3.1` model will be downloaded and saved as `my-model.gguf`.

### Use custom template

```shell
ollama-model-generator --from gemma2 --template my-template.txt
ollama-create --template my-template.txt gemma2
```

This will download the Gemma 2 model but use the local `my-template.txt` file as prompt template.

If `my-template.txt` doesn't exist, the template from the Gemma 2 model will be downloaded and saved as `my-template.txt`.

### Remove parameters

```shell
ollama-create --no-params gemma2
```

This will download the Gemma 2 model but removes all parameter instructions.

### Save all model files in custom location

```shell
ollama-create --dir ./models/gemma gemma2
```

This will download the Gemma 2 model and save all Ollama artifacts to the `./models/gemma/` directory.
Symlinks in the Ollama blob store are created for all files.


### Print GGUF metadata

```shell
ollama-model-generator --show --model my-model.gguf
ollama-create --metadata my-model.gguf
```

Prints the GGUF metadata of the model file as JSON.
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
## Reporting a Vulnerability

To report a security issue, please report them using
the [GitHub Security Advisory Form](https://github.com/GenericMale/ollama-model-generator/security/advisories/new) with a
the [GitHub Security Advisory Form](https://github.com/GenericMale/ollama-create-nodejs/security/advisories/new) with a
description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the
issue.
Loading

0 comments on commit 48fe32a

Please sign in to comment.