Skip to content

Commit

Permalink
IT'S ALIVEEEEEEEEEEEEEEE (cherry-picked)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Mar 8, 2024
1 parent bed7784 commit a433349
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pets-gd/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# Source:
# https://huggingface.co/rustformers/bloom-ggml
# https://huggingface.co/models?other=llm-rs
#
# This specific model is from
# https://huggingface.co/rustformers/bloom-ggml/blob/main/bloom-1b7-q4_0.bin
assets/llm.bin

# Godot 4+ specific ignores
.godot/
19 changes: 17 additions & 2 deletions pets-lib/src/llm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
use crate::prelude::*;

use io::Write;
use llm::models::Gpt2;

fn load_llm() -> Gpt2 {
use llm::models::Bloom;
use llm::Model as _;
use llm::{InferenceFeedback, InferenceResponse, Prompt};

/// get the path of the pretrained model
fn get_llm_path() -> Result<PathBuf> {
// Open file in read mode
let model_file = GFile::open("res://assets/llm.bin", ModeFlags::READ)?;

let path = model_file.path_absolute().to_string();

path.parse()
.map_err(|e| anyhow!("Failed to parse path: {}", e))
}

fn load_llm() -> Bloom {
let model_path = get_llm_path().unwrap();
// load a GGML model from disk
llm::load(
Path::new("/path/to/model"),
Expand Down

1 comment on commit a433349

@Lamby777
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took this one from the llm branch because git was saying the llm.bin file was untracked and i didn't want to accidentally git add -A while it wasn't in the gitignore yet

Please sign in to comment.