init
This commit is contained in:
109
README.md
Normal file
109
README.md
Normal file
@@ -0,0 +1,109 @@
|
||||
# Ollama Models
|
||||
|
||||
A small collection of Ollama Modelfiles centered on Google’s Gemma 3 Mini 2B (`gemma3n:e2b`). It includes two task‑focused models that work well together for Git workflows:
|
||||
|
||||
- git-diff-analyzer: turns a staged unified diff into strict JSON.
|
||||
- git-commit-writer: converts that JSON (or a raw diff) into a Conventional Commit message.
|
||||
|
||||
The goal is fast, local, reproducible commit assistance with minimal ceremony.
|
||||
|
||||
## Quick Start
|
||||
|
||||
Prerequisites:
|
||||
|
||||
- Ollama installed and running (see https://ollama.com/download)
|
||||
- A Git repo with staged changes for the examples
|
||||
|
||||
1) Pull the base model once:
|
||||
|
||||
```bash
|
||||
ollama pull gemma3n:e2b
|
||||
```
|
||||
|
||||
2) Build the specialized models from the included Modelfiles:
|
||||
|
||||
```bash
|
||||
# Build analyzer
|
||||
ollama create git-diff-analyzer-gemma3n-e2b \
|
||||
-f gemma3n-e2b/git-diff-analyzer/Modelfile
|
||||
|
||||
# Build commit writer
|
||||
ollama create git-commit-writer-gemma3n-e2b \
|
||||
-f gemma3n-e2b/git-commit-writer/Modelfile
|
||||
```
|
||||
|
||||
3) Use them together (pipeline):
|
||||
|
||||
```bash
|
||||
git diff --staged \
|
||||
| ollama run git-diff-analyzer-gemma3n-e2b \
|
||||
| ollama run git-commit-writer-gemma3n-e2b
|
||||
```
|
||||
|
||||
This prints a ready‑to‑use Conventional Commit message to stdout.
|
||||
|
||||
## Usage Details
|
||||
|
||||
- git-diff-analyzer
|
||||
- Input: unified diff (e.g., `git diff --staged`).
|
||||
- Output: a single JSON object with summary, per‑file highlights, and footers (see `gemma3n-e2b/git-diff-analyzer/Modelfile` for the exact schema and guidance).
|
||||
- Decoding is tuned for determinism (`temperature 0.1`).
|
||||
|
||||
- git-commit-writer
|
||||
- Preferred input: the analyzer’s JSON. Fallback: a raw diff.
|
||||
- Output: ONLY a Conventional Commit message (no backticks or extra prose), wrapped at ~72 chars.
|
||||
- Decoding is slightly more open (`temperature 0.2`) while keeping consistency.
|
||||
|
||||
Tip: If you want to inspect or edit the analyzer JSON before generating a message:
|
||||
|
||||
```bash
|
||||
git diff --staged \
|
||||
| ollama run git-diff-analyzer-gemma3n-e2b \
|
||||
| tee /tmp/diff-analysis.json
|
||||
|
||||
cat /tmp/diff-analysis.json \
|
||||
| ollama run git-commit-writer-gemma3n-e2b
|
||||
```
|
||||
|
||||
## Repository Layout
|
||||
|
||||
```
|
||||
gemma3n-e2b/
|
||||
Modelfile # Generated by `ollama show` (pinned to a local blob)
|
||||
git-diff-analyzer/Modelfile # Build with `FROM gemma3n:e2b`
|
||||
git-commit-writer/Modelfile # Build with `FROM gemma3n:e2b`
|
||||
```
|
||||
|
||||
Note on the top‑level `gemma3n-e2b/Modelfile`: it was generated via `ollama show` and references a local blob path in `FROM`. For portability, prefer the two task‑specific Modelfiles which already use `FROM gemma3n:e2b` and can be built anywhere after you `ollama pull` the base.
|
||||
|
||||
## Git Convenience Alias (optional)
|
||||
|
||||
Add a quick alias to print a suggested commit message from your staged changes:
|
||||
|
||||
```ini
|
||||
[alias]
|
||||
ai-commit = "!f() { \
|
||||
git diff --staged | \
|
||||
ollama run git-diff-analyzer-gemma3n-e2b | \
|
||||
ollama run git-commit-writer-gemma3n-e2b; \
|
||||
}; f"
|
||||
```
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
git ai-commit
|
||||
```
|
||||
|
||||
## Notes & Troubleshooting
|
||||
|
||||
- Stage changes first: `git add -p` or `git add <files>` before running.
|
||||
- Very large diffs may lead to longer runtimes; consider committing in smaller chunks.
|
||||
- If your environment lacks `gemma3n:e2b`, run `ollama pull gemma3n:e2b` before `ollama create`.
|
||||
- You can swap the base in Modelfiles to another small instruct model if you prefer.
|
||||
|
||||
## Licensing
|
||||
|
||||
- Base model: Gemma Terms of Use apply to the underlying model; a copy of the terms is embedded in `gemma3n-e2b/Modelfile`.
|
||||
- Modelfiles/system prompts in this repository are provided as-is; ensure your usage complies with the Gemma Terms of Use and your local policies.
|
||||
|
||||
Reference in New Issue
Block a user