1.0.21 • Published 5 months ago

llm-info v1.0.21

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

llm-info

NPM version CI

Information on LLM models, context window token limit, output token limit, pricing and more, developed by 16x Prompt team.

Information provided includes:

  • context window token limit
  • output token limit
  • pricing
  • tokenizerId for loading tokenizer from @xenova/transformers
  • and more

Models included:

  • GPT-4
  • GPT-4 Turbo
  • GPT-4o
  • GPT-4o mini
  • GPT-4o Long Output
  • o1
  • Claude 3.5 Sonnet
  • ... and more new models

Non-models (model-like) included:

  • ChatGPT

Install:

$ yarn add llm-info

Usage

// Models
import { AllModels, ModelEnum, NonModelEnum, ModelInfoMap } from 'llm-info';

console.log(AllModels);
/*
[
  'gpt-4',
  'gpt-4o',
  'gpt-4-turbo',
  'gpt-4o-64k-output-alpha',
  'gpt-4o-mini',
  'claude-3-5-sonnet-20240620'
]
*/

console.log(AllModelLikes);
/*
[
  'gpt-4',
  'gpt-4o',
  'gpt-4-turbo',
  'gpt-4o-64k-output-alpha',
  'gpt-4o-mini',
  'claude-3-5-sonnet-20240620',
  'chatgpt'
]
*/

// Model Info
const modelInfo = ModelInfoMap['gpt-4o'];
console.log(modelInfo);
/*
{
  name: 'GPT-4o',
  provider: 'openai',
  contextWindowTokenLimit: 128000,
  outputTokenLimit: 4096,
  pricePerMillionInputTokens: 5,
  pricePerMillionOutputTokens: 15,
  tokenizerId: 'Xenova/gpt-4o'
}
*/

// Tokenizer
import { AutoTokenizer } from '@xenova/transformers';
const testSentence =
  "Many words map to one token, but some don't: indivisible.";
const results: string[] = [];
for (let i = 0; i < AllModels.length; i++) {
  const model = AllModels[i];
  if (ModelInfoMap[model].tokenizerId) {
    const tokenizer = await AutoTokenizer.from_pretrained(
      ModelInfoMap[model].tokenizerId
    );
    const tokens = tokenizer.encode(testSentence);
    results.push(`${model}: ${tokens.length}`);
  }
}
console.log(`Test sentence: ${testSentence}\n${results.join('\n')}`);
// Test sentence: Many words map to one token, but some don't: indivisible.
// gpt-4: 15
// gpt-4o: 14
// gpt-4o-mini: 14
// claude-3-5-sonnet-20240620: 16

Testing

$ yarn test
1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

8 months ago

1.0.21

5 months ago

1.0.20

6 months ago

1.0.16

9 months ago

1.0.15

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

11 months ago

1.0.10

12 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago