Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
fix(cli): in info, elide known large items
Browse files Browse the repository at this point in the history
  • Loading branch information
philpax committed Oct 30, 2023
1 parent be709ed commit a728852
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions binaries/llm-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{
convert::Infallible,
fmt,
fs::File,
io::{BufReader, BufWriter, Read, Seek},
path::Path,
Expand All @@ -9,7 +10,7 @@ use clap::Parser;
use cli_args::Args;
use color_eyre::eyre;
use is_terminal::IsTerminal;
use llm::ggml_format::gguf;
use llm::ggml_format::gguf::{self, MetadataValue};

mod cli_args;
mod interactive;
Expand Down Expand Up @@ -150,11 +151,29 @@ fn info(args: &cli_args::Info) -> eyre::Result<()> {

log::info!("Non-array parameters:");
for (metadata_key, metadata_value) in gguf.metadata.iter() {
if metadata_value.as_array().is_some() {
continue;
struct ValueDisplay<'a>(Option<&'a MetadataValue>);
impl fmt::Debug for ValueDisplay<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(value) = self.0 {
write!(f, "{:?}", value)
} else {
write!(f, "[elided due to size]")
}
}
}

log::info!("- {}: {:?}", metadata_key, metadata_value);
let elide_due_to_size =
metadata_value.as_array().is_some() || metadata_key == "tokenizer.huggingface.json";

log::info!(
"- {}: {:?}",
metadata_key,
ValueDisplay(if elide_due_to_size {
None
} else {
Some(metadata_value)
})
);
}

if let Ok(tokenizer) = llm::tokenizer::GgufEmbeddedTokenizer::from_metadata(&gguf.metadata) {
Expand Down

0 comments on commit a728852

Please sign in to comment.