Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new_llama_icl #15

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions LLMFactCheck_ABOUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ The accuracy results are visually represented through pie charts for both standa
<figcaption>Llama Model Accuracy on All Labeled Dataset</figcaption>
<img src="./img/llama_accuracy_on_all_labeled_df.png" alt="Llama model accuracy on all labeled dataset" style="width: 100%; max-width: 400px;">
</figure>
<h3 style="text-align: center">Llama-2-7B-GGUF - test size = 0.3</h3>
<div style="display: flex; justify-content: center; flex-wrap: wrap; gap: 20px;">
<!-- Llama Model Accuracy -->
<figure style="text-align: center; border: 1px solid lightgrey; padding: 10px;">
<figcaption>Llama Model Accuracy on Test Dataset</figcaption>
<img src="./img/llama_7B_0.3_icl.png" alt="Llama model accuracy on test dataset" style="width: 100%; max-width: 400px;">
</figure>
</div>

<!-- GPT-3.5 Turbo Model Accuracy -->
<figure style="text-align: center; border: 1px solid lightgrey; padding: 10px;">
Expand Down Expand Up @@ -107,15 +115,18 @@ The evaluation of model accuracies has provided the following insights:

| Model | Dataset Type | Accuracy |
|-----------------------|-----------------------|---------:|
| Llama | Test | 44% |
| Llama | test size = 0.3 | 44% |
| Llama | All Labeled | 49% |
| GPT-3.5 Turbo | Test (Standard) | 64% |
| Llama-2-7B-GGUF | test size = 0.3 | 71% |
| GPT-3.5 Turbo | test size = 0.3 | 64% |
| GPT-3.5 Turbo | All Labeled (Standard)| 58% |
| GPT-3.5 Turbo (ICL) | Test | 73% |
| GPT-4.0 | Test (Standard) | 48% |
| GPT-3.5 Turbo (ICL) | test size = 0.3 | 73% |
| GPT-4.0 | test size = 0.3 | 48% |
| GPT-4.0 | All Labeled (Standard)| 59% |
| GPT-4.0 (ICL) | Test | 73% |
| GPT-4.0 (ICL) | test size = 0.3 | 73% |


>Llama-2-7B-GGUF - test size = 0.3
- **Llama Model Accuracy**:
- On the test dataset: 44%
- On the all labeled dataset: 49%
Expand Down
Binary file added img/llama_7B_0.3_icl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 14 additions & 5 deletions src/load_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"""
if model_type == 'llama':
# Load a Llama model
model_name = "TheBloke/Llama-2-13B-chat-GGML"
model_path = hf_hub_download(repo_id=model_name, filename="llama-2-13b-chat.ggmlv3.q5_1.bin")
model_name = "TheBloke/Llama-2-7B-GGUF"
model_path = hf_hub_download(repo_id=model_name, filename="llama-2-7b.Q4_K_M.gguf")

Check warning on line 31 in src/load_model.py

View check run for this annotation

Codecov / codecov/patch

src/load_model.py#L30-L31

Added lines #L30 - L31 were not covered by tests
model = Llama(model_path=model_path, n_threads=2, n_batch=512, n_gpu_layers=32)
if use_icl:
return prepare_icl(model, model_type)
Expand Down Expand Up @@ -60,11 +60,20 @@

"""
df = pd.read_csv(file_path)
train_df, test_df = train_test_split(df, test_size=0.3, random_state=42)
test_df.to_csv(os.path.join('data', f'test_df_{model_type}_icl.csv'), index=False)

if not os.path.exists(os.path.join('data', f'test_df_{model_type}_icl.csv')) or \

Check warning on line 64 in src/load_model.py

View check run for this annotation

Codecov / codecov/patch

src/load_model.py#L64

Added line #L64 was not covered by tests
not os.path.exists(os.path.join('data', f'train_df_{model_type}_icl.csv')):

train_df, test_df = train_test_split(df, test_size=0.7, random_state=42)

Check warning on line 67 in src/load_model.py

View check run for this annotation

Codecov / codecov/patch

src/load_model.py#L67

Added line #L67 was not covered by tests

test_df.to_csv(os.path.join('data', f'test_df_{model_type}_icl.csv'), index=False)
train_df.to_csv(os.path.join('data', f'train_df_{model_type}_icl.csv'), index=False)

Check warning on line 70 in src/load_model.py

View check run for this annotation

Codecov / codecov/patch

src/load_model.py#L69-L70

Added lines #L69 - L70 were not covered by tests
else:
train_df = pd.read_csv(os.path.join('data', f'train_df_{model_type}_icl.csv'))

Check warning on line 72 in src/load_model.py

View check run for this annotation

Codecov / codecov/patch

src/load_model.py#L72

Added line #L72 was not covered by tests

context_entries = train_df.sample(n=10)

context = context_entries.apply(
lambda row: f"{row['Question']} Answer: {'Yes' if row['Label'] else 'No'}\n",
axis=1).str.cat()
return model, context
return model, context

Check warning on line 79 in src/load_model.py

View check run for this annotation

Codecov / codecov/patch

src/load_model.py#L79

Added line #L79 was not covered by tests