char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
e2eb39e81
char/aliceai-t5-moe
1#!/usr/bin/env python3 2 3import argparse 4import sys 5from common import compare_tokens # type: ignore[import-not-found, ty:unresolved-import] 6 7 8def parse_arguments (): 9parser = argparse .ArgumentParser ( 10description = 'Compare tokens between two models' , 11formatter_class = argparse .RawDescriptionHelpFormatter , 12epilog = """ 13Examples: 14%(prog)s pytorch-gemma-3-270m-it llamacpp-gemma-3-270m-it-bf16 15""" 16 ) 17parser .add_argument ( 18'original' , 19help = 'Original model name' 20 ) 21parser .add_argument ( 22'converted' , 23help = 'Converted model name' 24 ) 25parser .add_argument ( 26'-s' ,'--suffix' , 27default = '' , 28help = 'Type suffix (e.g., "-embeddings")' 29 ) 30parser .add_argument ( 31'-d' ,'--data-dir' , 32default = 'data' , 33help = 'Directory containing token files (default: data)' 34 ) 35parser .add_argument ( 36'-v' ,'--verbose' , 37action = 'store_true' , 38help = 'Print prompts from both models' 39 ) 40return parser .parse_args () 41 42 43def main (): 44args = parse_arguments () 45 46if args .verbose : 47from pathlib import Path 48data_dir = Path (args .data_dir ) 49 50prompt1_file = data_dir / f" { args . original } { args . suffix } -prompt.txt" 51prompt2_file = data_dir / f" { args . converted } { args . suffix } -prompt.txt" 52 53if prompt1_file .exists (): 54f"\nOriginal model prompt ( { args . original } ):" ) 55f" { prompt1_file . read_text (). strip () } " ) 56 57if prompt2_file .exists (): 58f"\nConverted model prompt ( { args . converted } ):" ) 59f" { prompt2_file . read_text (). strip () } " ) 60 61result = compare_tokens ( 64args .original , 65args .converted , 66type_suffix = args .suffix , 67output_dir = args .data_dir 68 ) 69 70# Enable the script to be used in shell scripts so that they can check 71# the exit code for success/failure. 72sys .exit (0 if result else 1 ) 73 74 75if __name__ == "__main__" : 76main ()