Skip to content

Commit

Permalink
readme edit
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytimm committed Aug 10, 2024
1 parent 6b52f24 commit 3edda8e
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# hollr

An R package providing a unified interface for text completion via local
An R package providing a unified interface for chat completion via local
and cloud-based LLMs, tailored for text annotation tasks.

#### Features
Expand All @@ -30,31 +30,6 @@ and cloud-based LLMs, tailored for text annotation tasks.

------------------------------------------------------------------------

## Conda environment & reticulate

``` bash
# Create and activate a new conda environment with Python 3.9
conda create -n llm_base python=3.9 -y
conda activate llm_base

# Update all packages in the environment
conda update --all -y

# Install required packages with conda
conda install nmslib pandas numpy spacy -c conda-forge -y
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia -y

# Install additional packages with pip
pip install transformers packaging ninja flash-attn --no-build-isolation accelerate protobuf auto-gptq \
"git+https://github.com/PanQiWei/[email protected]" optimum tiktoken sentencepiece
```

``` r
# Set environment variables and use conda environment
Sys.setenv(RETICULATE_PYTHON = file.path(miniconda_path, "envs", env_name, "bin/python"))
reticulate::use_condaenv(condaenv = env_name, conda = file.path(miniconda_path, "bin/conda"))
```

## Some prompts and data

### Sample prompts
Expand Down Expand Up @@ -182,16 +157,16 @@ class_task1 |> knitr::kable()

| id | annotator_id | attempts | success | pol_ideo | survey_long | demo_geo | health_policy | misinfo_media_trust |
|:------|:--------|------:|:-----|:------|:--------|:------|:---------|:-------------|
| 30247057 | 1mqmCu6hCS | 1 | TRUE | TRUE | TRUE | FALSE | FALSE | TRUE |
| 37947551 | 1mqmCu6hCS | 1 | TRUE | TRUE | FALSE | TRUE | TRUE | FALSE |
| 28895229 | 1mqmCu6hCS | 1 | TRUE | TRUE | FALSE | FALSE | TRUE | FALSE |
| 34341651 | 1mqmCu6hCS | 1 | TRUE | TRUE | TRUE | TRUE | TRUE | FALSE |
| 25316309 | 1mqmCu6hCS | 1 | TRUE | FALSE | FALSE | FALSE | TRUE | FALSE |
| 22904584 | 1mqmCu6hCS | 1 | TRUE | TRUE | FALSE | FALSE | FALSE | FALSE |
| 7183563 | 1mqmCu6hCS | 1 | TRUE | TRUE | TRUE | FALSE | TRUE | FALSE |
| 33199928 | 1mqmCu6hCS | 1 | TRUE | TRUE | TRUE | TRUE | TRUE | FALSE |
| 35270435 | 1mqmCu6hCS | 1 | TRUE | TRUE | TRUE | TRUE | FALSE | FALSE |
| 35250760 | 1mqmCu6hCS | 1 | TRUE | TRUE | TRUE | TRUE | FALSE | FALSE |
| 30247057 | os8UHcrJQG | 1 | TRUE | TRUE | TRUE | FALSE | FALSE | TRUE |
| 37947551 | os8UHcrJQG | 1 | TRUE | TRUE | FALSE | TRUE | TRUE | FALSE |
| 28895229 | os8UHcrJQG | 1 | TRUE | TRUE | FALSE | FALSE | TRUE | FALSE |
| 34341651 | os8UHcrJQG | 1 | TRUE | TRUE | TRUE | TRUE | TRUE | FALSE |
| 25316309 | os8UHcrJQG | 1 | TRUE | FALSE | FALSE | TRUE | TRUE | FALSE |
| 22904584 | os8UHcrJQG | 1 | TRUE | TRUE | TRUE | FALSE | FALSE | FALSE |
| 7183563 | os8UHcrJQG | 1 | TRUE | TRUE | TRUE | TRUE | TRUE | FALSE |
| 33199928 | os8UHcrJQG | 1 | TRUE | TRUE | TRUE | TRUE | TRUE | FALSE |
| 35270435 | os8UHcrJQG | 1 | TRUE | TRUE | TRUE | TRUE | FALSE | FALSE |
| 35250760 | os8UHcrJQG | 1 | TRUE | TRUE | TRUE | TRUE | FALSE | FALSE |

### Parallel processing

Expand All @@ -210,11 +185,38 @@ class_task2 <- hollr::hollr(

## Local LLMs

### Conda environment & reticulate

> For running local models.
``` bash
# Create and activate a new conda environment with Python 3.9
conda create -n llm_base python=3.9 -y
conda activate llm_base

# Update all packages in the environment
conda update --all -y

# Install required packages with conda
conda install nmslib pandas numpy spacy -c conda-forge -y
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia -y

# Install additional packages with pip
pip install transformers packaging ninja flash-attn --no-build-isolation accelerate protobuf auto-gptq \
"git+https://github.com/PanQiWei/[email protected]" optimum tiktoken sentencepiece
```

``` r
# Set environment variables and use conda environment
Sys.setenv(RETICULATE_PYTHON = file.path(miniconda_path, "envs", env_name, "bin/python"))
reticulate::use_condaenv(condaenv = env_name, conda = file.path(miniconda_path, "bin/conda"))
```

``` r
llm = 'meta-llama/Meta-Llama-3.1-8B-Instruct'
```

### Sequential
### Sequential processing

``` r
local_seq <- hollr::hollr(
Expand Down

0 comments on commit 3edda8e

Please sign in to comment.