<commit_before>const tokenizerPath = chrome.runtime.getURL('tokenizer.json');

async function main() {
  // Load tokenizer dictionary
  const tokenizerResponse = await fetch(tokenizerPath);
  const tokenizerObj = await tokenizerResponse.json();
  const tokenizer = new Map(Object.entries(tokenizerObj));

  console.log(tokenizer.entries());
  console.log(tokenizer.get('bread'));
}

main();<commit_msg>Add ML model loading in Chrome extension<commit_after>const mlModelPath = chrome.runtime.getURL('model/model.json');
const tokenizerPath = chrome.runtime.getURL('tokenizer.json');

async function main() {
  // Load tokenizer dictionary
  const response = await fetch(tokenizerPath);
  const tokenizerObj = await response.json();
  const tokenizer = new Map(Object.entries(tokenizerObj));

  console.log(tokenizer.entries());
  console.log(`Tokenizer dict size: ${tokenizer.size}`);

  // Attempt to load ML model
  const model = await tf.loadLayersModel(mlModelPath);
  console.log(model.summary());
}

main();
{'fraction_non_alphanumeric': 0.13043478260869565, 'fraction_numerical': 0.0, 'mean_word_length': 5.577922077922078, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4414942', 'n_tokens_mistral': 298, 'n_tokens_neox': 290, 'n_words': 69}