Skip to content

Commit

Permalink
Merge pull request #32 from hangyav/feat/ollama
Browse files Browse the repository at this point in the history
Feat/ollama
  • Loading branch information
hangyav authored Jun 20, 2024
2 parents 062dd38 + 70de2e1 commit 2a4d5e0
Show file tree
Hide file tree
Showing 5 changed files with 387 additions and 6 deletions.
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ _This tool is in early development._
The following tools run on the local system:

* [LanguageTool](https://languagetool.org): Mainly for development purposes, see [ltex-ls](https://github.com/valentjn/ltex-ls) for a more mature implementation.
* [Gramformer](https://github.com/PrithivirajDamodaran/Gramformer): Neural network based system.
* Gramformer needs to be installed manually:

```pip install git+https://github.com/PrithivirajDamodaran/Gramformer.git```
* [Ollama](https://www.ollama.com): Run LLMs efficiently on your local machine.
It supports diagnostics, code actions and prompt based text generation.
* Ollama needs to be [installed manually](https://www.ollama.com/download) first.
* Various [LLMs](https://www.ollama.com/library) are supported, such as `Llama 3`, `Gemma` or `Mixtra`. Suggested model is `Phi3`, due to its speed, size and accuracy.
* hf_checker: Huggingface `text2text-generation` pipeline based analyser. See the [flan-t5-large-grammar-synthesis](https://huggingface.co/pszemraj/flan-t5-large-grammar-synthesis) model for an example.
<details><summary>Models</summary>
<ul>
Expand Down Expand Up @@ -68,6 +68,10 @@ magic command (see the OpenAI analyser below).
</ul>
</details>
* [hf_completion](https://huggingface.co/docs/transformers/task_summary#language-modeling): Huggingface `fill-mask` pipeline based text completion.
* [Gramformer](https://github.com/PrithivirajDamodaran/Gramformer): Neural network based system.
* Gramformer needs to be installed manually:

```pip install git+https://github.com/PrithivirajDamodaran/Gramformer.git```

### Tools using remote services

Expand Down Expand Up @@ -135,6 +139,17 @@ textLSP = {
on_change = false,
}
},
ollama = {
enabled = true,
check_text = {
on_open = false,
on_save = true,
on_change = false,
},
model = "phi3:3.8b-instruct", -- smaller but faster model
-- model = "phi3:14b-instruct", -- more accurate
max_token = 50,
},
gramformer = {
-- gramformer dependency needs to be installed manually
enabled = false,
Expand All @@ -158,7 +173,7 @@ textLSP = {
}
},
hf_instruction_checker = {
enabled = true,
enabled = false,
gpu = false,
quantize=32,
model='grammarly/coedit-large',
Expand All @@ -170,7 +185,7 @@ textLSP = {
}
},
hf_completion = {
enabled = true,
enabled = false,
gpu = false,
quantize=32,
model='bert-base-multilingual-cased',
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def read(fname):
'sortedcontainers==2.4.0',
'bitsandbytes==0.43.1',
'langdetect==1.0.9',
'ollama==0.2.0',
],
extras_require={
'dev': [
Expand Down
15 changes: 15 additions & 0 deletions tests/analysers/ollama_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from textLSP.analysers.ollama import OllamaAnalyser
from textLSP.types import ConfigurationError


def test_init():
# there's no easy way to test this. So this is just a
# placeholder for test coverage.
try:
return OllamaAnalyser(
None,
{OllamaAnalyser.CONFIGURATION_MODEL: 'DUMMY_MODEL'},
'ollama',
)
except ConfigurationError:
pass
1 change: 1 addition & 0 deletions textLSP/analysers/ollama/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .ollama import OllamaAnalyser
Loading

0 comments on commit 2a4d5e0

Please sign in to comment.