Skip to content

Commit

Permalink
merging origin/maun
Browse files Browse the repository at this point in the history
  • Loading branch information
leonpolak committed May 29, 2024
2 parents 7d6cac3 + 2f29e9d commit cb4f638
Show file tree
Hide file tree
Showing 26 changed files with 1,609 additions and 497 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:

jobs:
build:
if: false
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
69 changes: 31 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Universal LLMs
# Universal LLM

This module should manage interactions with AI language models. For starters: Openai, Huggingface, Ollama and Elevenlabs.

Expand All @@ -10,24 +10,6 @@ Install [ffmpeg](https://ffmpeg.org/) for audio and video processing.
npm install
```

Create in the root directory .env file with the following content:

```
OPENAI_API_KEY=<string?>
HUGGINGFACE_TOKEN=<string?>
ELEVENLABS_API_KEY=<string?>
```

Fill the .env file with the following data:

- Register free openai account and get the API key (for developers of LLM module)
- Register free huggingface account and get the token (for developers of LLM module)
- Register free elevenlabs account and get the API key (for developers using Elevenlabs speech-to-text module)

Check periodically changes of the package.json file and install the new dependencies.

All non private global settings, like port numbers etc. you should store in config.json

### LLM

**Openai** - there is the connector class managing many kinds of interactions with the Openai API, mostly self explanatory.
Expand All @@ -40,7 +22,7 @@ To compare manually performance and quality of open source models in parallel yo
**Ollama** - there is the connector class managing many kinds of interactions with multiple local LLMs.
You should install [Ollama](https://github.com/ollama/ollama) on your local machine to use this module. Then run following commands (with your preferred model - in this case llama2):

```
```bash
ollama serve
ollama run llama2
```
Expand All @@ -49,13 +31,31 @@ ollama run llama2

## Testing

Running for all tests:

```bash
npm t
```

Alternatively, you can check manually if a method works by placing following code in the main.js file in the root (in this case we testing Elevenlabs module):
Running for single test file with environments file:

```bash
node --env-file=.env --test 'test/openai.js'
```

Running for single test in a test file:

```bash
node --env-file=.env --test --test-name-pattern="/Text completion/" 'test/openai.js'
```

## Usage

**OpenAi Example**

```javascript
'use strict';

const { openai } = require('./lib');

const { Chat } = openai;
Expand All @@ -74,14 +74,6 @@ If LOG_API_CALL_TIME config variable is set to true, each method should measure

If LOG_API_CALL_RESULT config variable is set to true, each method should print the full api responce to pick required portion of data to return from a method.

For those who unfamiliar with backend, you run following command in the terminal:

```bash
node --env-file=.env main.js
```

Just don't forget to remove the code from the index.js file after testing.

## Diagnostics

I would like to use [Clinic.js](https://clinicjs.org/) for diagnostics, but we may set other systems in parrallel.
Expand All @@ -107,15 +99,16 @@ Peak a module you see a potential in and start working on it.

## TODO list

- Write tests for openaAI assisitants
- Finish Huggingface module and write JEST tests
- Add price calculation for all methods that return usage statistics
- Add price estimation function for all methods, that do not return usage statistics
- Add "my\_" prefix to all generated dusting tests files, so git will ignore them
- Make frontend allowing to interact with multiple LLMs in parralel and compare output
- Connect the frontend to openai, huggingface and ollama modules
- Make frontend to visualise dialogues and all other interactions with LLMs
- Allow dinamic API_KEY definition (stored on frontend side)
- [x] Make LLM to be separate subrepository, with all dependencies and tests.
- [ ] Write tests for openaAI assisitants
- [ ] Finish Huggingface module and write tests
- [ ] Add price calculation for all methods that return usage statistics
- [ ] Add price estimation function for all methods, that do not return usage statistics
- [x] Add "my\_" prefix to all generated dusting tests files, so git will ignore them
- [ ] Make frontend allowing to interact with multiple LLMs in parralel and compare output
- [ ] Connect the frontend to openai, huggingface and ollama modules
- [ ] Make frontend to visualise dialogues and all other interactions with LLMs
- [x] Allow dynamic API_KEY definition (stored on frontend side)

##

Expand Down
42 changes: 42 additions & 0 deletions lib/huggingface/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"DEFAULT_MODELS": {
"language": {
"fillMask": "bert-base-uncased",
"summarization": "facebook/bart-large-cnn",
"questionAnswering": "deepset/roberta-base-squad2",
"tableQuestionAnswering": "google/tapas-base-finetuned-wtq",
"textClassification": "distilbert-base-uncased-finetuned-sst-2-english",
"textGeneration": "gpt2",
"textGenerationStream": "google/flan-t5-xxl",
"tokenClassification": "dbmdz/bert-large-cased-finetuned-conll03-english",
"translation": "t5-base",
"zeroShotClassification": "facebook/bart-large-mnli",
"sentenceSimilarity": "sentence-transformers/paraphrase-xlm-r-multilingual-v1"
},
"audio": {
"automaticSpeechRecognition": "facebook/wav2vec2-large-960h-lv60-self",
"audioClassification": "superb/hubert-large-superb-er",
"textToSpeech": "espnet/kan-bayashi_ljspeech_vits",
"audioToAudio": "speechbrain/sepformer-wham"
},
"computerVision": {
"imageClassification": "google/vit-base-patch16-224",
"objectDetection": "facebook/detr-resnet-50",
"imageSegmentation": "facebook/detr-resnet-50-panoptic",
"imageToText": "nlpconnect/vit-gpt2-image-captioning",
"textToImage": "stabilityai/stable-diffusion-2",
"imageToImage": "lllyasviel/sd-controlnet-depth",
"zeroShotImageClassification": "openai/clip-vit-large-patch14-336"
},
"multimodal": {
"featureExtraction": "sentence-transformers/distilbert-base-nli-mean-tokens",
"visualQuestionAnswering": "dandelin/vilt-b32-finetuned-vqa",
"documentQuestionAnswering": "impira/layoutlm-document-qa"
},
"tabular": {
"tabularRegression": "scikit-learn/Fish-Weight",
"tabularClassification": "vvmnnnkv/wine-quality"
}
},
"DEFAULT_VOICE": "onyx"
}
Loading

0 comments on commit cb4f638

Please sign in to comment.