Skip to content

Commit

Permalink
Merge branch 'main' into hf-tokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
philpax committed May 24, 2023
2 parents d4acc9b + 73e5bb3 commit 9baed44
Show file tree
Hide file tree
Showing 31 changed files with 340 additions and 1,513 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"rust-analyzer.cargo.features": ["convert"]
"rust-analyzer.cargo.features": []
}
68 changes: 1 addition & 67 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion binaries/generate-ggml-bindings/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::PathBuf;

fn main() {
let bindings = bindgen::Builder::default()
.header("crates/ggml/sys/bindings.h")
.header("crates/ggml/sys/ggml/include/ggml/ggml.h")
// Suppress some warnings
.raw_line("#![allow(non_upper_case_globals)]")
.raw_line("#![allow(non_camel_case_types)]")
Expand Down
11 changes: 7 additions & 4 deletions binaries/llm-cli/src/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,17 @@ pub struct Perplexity {

#[derive(Parser, Debug)]
pub struct Info {
/// The model to inspect
/// The model to inspect.
#[arg(long, short = 'm')]
pub model_path: PathBuf,

/// Whether or not to dump the entire vocabulary
/// Show all of the tensors in the model, including their names, formats and shapes.
#[arg(long, short = 't')]
pub tensors: bool,

/// Show all of the tokens in the vocabulary.
#[arg(long, short = 'v')]
pub dump_vocabulary: bool,
pub vocabulary: bool,
}

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -371,7 +375,6 @@ impl ModelLoad {
prefer_mmap: !self.no_mmap,
context_size: self.num_ctx_tokens,
lora_adapters: self.lora_paths.clone(),
..Default::default()
};

let mut sp = Some(spinoff::Spinner::new(
Expand Down
25 changes: 12 additions & 13 deletions binaries/llm-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn infer<M: llm::KnownModel + 'static>(
&mut rng,
&llm::InferenceRequest {
prompt: prompt.as_str().into(),
parameters: Some(&inference_params),
parameters: &inference_params,
play_back_previous_tokens: session_loaded,
maximum_token_count: args.generate.num_predict,
},
Expand Down Expand Up @@ -159,20 +159,19 @@ fn info<M: llm::KnownModel + 'static>(args: &cli_args::Info) -> Result<()> {

log::info!("Container type: {:?}", loader.container_type);
log::info!("Hyperparameters: {:?}", loader.hyperparameters);
log::info!(
"Tensors: {:?}",
loader
.tensors
.iter()
.map(|(name, tensor)| format!("{} ({:?})", name, tensor.element_type))
.collect::<Vec<_>>()
);
log::info!("Vocabulary size: {}", loader.vocabulary.len());

if args.dump_vocabulary {
log::info!("Dumping vocabulary:");
if args.vocabulary {
log::info!("Vocabulary:");
for i in 0..loader.vocabulary.len() {
log::info!("{}: {}", i, utf8_or_array(&loader.vocabulary.token(i)));
log::info!("- {}: {}", i, utf8_or_array(&loader.vocabulary.token(i)));
}
}

if args.tensors {
log::info!("Tensors:");
for (name, tensor) in &loader.tensors {
log::info!("- {} ({:?} {:?})", name, tensor.element_type, tensor.dims());
}
}

Expand Down Expand Up @@ -274,7 +273,7 @@ fn interactive<M: llm::KnownModel + 'static>(
&mut rng,
&llm::InferenceRequest {
prompt: "".into(),
parameters: Some(&inference_params),
parameters: &inference_params,
play_back_previous_tokens: session_loaded,
maximum_token_count: args.generate.num_predict,
},
Expand Down
95 changes: 0 additions & 95 deletions crates/ggml/src/legacy.rs

This file was deleted.

3 changes: 1 addition & 2 deletions crates/ggml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ mod context;
mod tensor;

pub mod format;
pub mod legacy;
pub mod util;

pub use context::Context;
Expand Down Expand Up @@ -140,7 +139,7 @@ pub enum Type {
F32,

/// Legacy: Quantized 4-bit (type 2).
/// This is not supported by modern `ggml` and is only here for use with [legacy].
/// This is not supported by modern `ggml` versions.
LegacyQ4_2,
}
impl From<Type> for sys::ggml_type {
Expand Down
2 changes: 0 additions & 2 deletions crates/ggml/sys/bindings.h

This file was deleted.

4 changes: 2 additions & 2 deletions crates/ggml/sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ fn main() {
let mut builder = cc::Build::new();

let build = builder
.files(["ggml/src/ggml.c", "legacy/qnt0.c"])
.includes(["ggml/include/ggml", "legacy"]);
.files(["ggml/src/ggml.c"])
.includes(["ggml/include/ggml"]);

// This is a very basic heuristic for applying compile flags.
// Feel free to update this to fit your operating system.
Expand Down
1 change: 0 additions & 1 deletion crates/ggml/sys/legacy/README.md

This file was deleted.

Loading

0 comments on commit 9baed44

Please sign in to comment.