GithubHelp home page GithubHelp logo

bad_ocr_embedding_test's Introduction

About

This experiment tests whether a large language model can "read past" OCR errors. Specifically, we identify a series of sentences from a corpus that contain OCR errors, which we then correct. Then, we send the erroneous sentence and the fixed sentence to a model and retrieve embeddings for both, with the hope that these embeddings will be interchangeable.

Process:

  1. Run the following:

    ./src/sample_sents.py --indir path/to/data --outfile path/to/sample.txt
    

    This will yank sentences from the documents using nltk's sent_tokenize() function. That's by no means a perfect method, but we just need some examples, so it'll do

  2. Manually read the sentences and identify ones with bad OCR. Place those in a new plaintext file. Each sentence should be on its own line

  3. Create a new plaintext file and, on each line, provide a corrected version of the sentences above. Ensure that the lines of each file contain properly aligned sentences.

  4. Embed the sentences with the model:

    ./src/llama_embed.py \
      --uncorrected path/to/uncorrected.txt \
      --corrected path/to/corrected.txt \
      --embeddings path/to/embeddings.jsonl \
      --model_path path/to/model
    
  5. Compare the embeddings in analysis.ipynb

  6. Optional: To compare multiple embedding types, run the following:

    ./src/shuffle_and_measure.py \
      --paths path/to/*.jsonl \
      --outfile path/to/output.csv
    

    This will use the shuffle_and_measure function in analysis.ipynb and store the result in a table

  7. Optional: Compare multiple embeddings in analysis_aggregate.ipynb

bad_ocr_embedding_test's People

Contributors

t-shoemaker avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.