Package: larch-readme
LARCH: Large Language Model-based Automatic Readme Creation with HeuristicsLARCH is an automatic readme generation system using language models.UsagePrerequisiteInstall LARCH with pip:pip install larch-readmePython CLIYou can then test out generation without setting up a server.larch --local --model openai/text-davinci-003 --openai-api-key ${YOUR_OPENAI_API_KEY}or you can rely on a server to do generation (See following for setting up a server):larch --endpoint https://${YOUR_SERVER_ADDRESS} --model openai/text-davinci-003ServerStart the server.OPENAI_API_KEY=${MY_API_KEY} larch-serverYou can accesshttp://localhost:8000/docsto see the API.You may want to specify--host ${YOUR_HOST_NAME_OR_IP_ADDRESS}if you intend to access from a remote machine.Both environmental variables are optional.
Spcify OPENAI_API_KEY if you want to allow users to use OpenAI-based models.
Specify ENTRYPOINT_EXTRACTOR if you want to use entrypoint-based generation (strongly recommended; trained withscript/entrypoint_extractor.py).You can limit the models to load withLOADED_MODELSenvironmental variable (not setting anything loads all models).
You can also load pretrained encoder-decoder model by passing json serialization mapping from their names to their paths withENCODER_DECODER_MODEL_PATHS.# This loads gpt2, gpt2-xl and a pretrained encoder-decoder model from ./path-to-model/LOADED_MODELS='gpt2,gpt2-xl'ENCODER_DECODER_MODEL_PATHS='{"my-encdec": "./path-to-model/"}'larch-server# This only loads a pretrained encoder-decoder model. Notice that empty LOADED_MODELS and unset LOADED_MODELS have different behaviors.LOADED_MODELS=''ENCODER_DECODER_MODEL_PATHS='{"my-encdec": "./path-to-model/"}'larch-serverYou can download VSCode plugin to interact with the server from:Coming soon!Usage with DockerBuild docker image (you need to set up proxy settings appriopriately if you are behind a proxy server).dockerbuild-tlarch.You may need to pass--build-arg CURL_CA_BUNDLE=""if you are behind a proxy and getting a SSL error.
WARNING: This disables SSL connection thus make your connection vulnerable against attacks.Then you can start the server with the following command:dockerrun\--rm\-p${YOUR_HOST_IP}:${PORT}:80/tcp\\larchYou need to pass-e OPENAI_API_KEY=${YOUR_OPENAI_API_KEY}if you wish to use OpenAI models.You may need to pass-e CURL_CA_BUNDLE=""if you are behind a proxy and getting a SSL error.
WARNING: This disables SSL connection thus make your connection vulnerable against attacks.DevelopmentAlternatively, you can run CLI without using pip for better debugging and development.pip install -r requirements.txt
export PYTHONPATH=`pwd`

# test out generation
python larch/cli.py --local --model gpt2

# start debug server
python larch/server.py --reload --log-level debugFor testing:pipinstall'pytest>=7.2.0''pytest-dependency>=0.5.1'exportPYTHONPATH=`pwd`py.test-vtestsModel Training and EvaluationTraining Encoder-Decoder ModelsYou can train your own Encoder-Decoder Model withscripts/finetune_encdec.py.# Make sure you have CUDA 11.6 installed# We do custom torch installation to enble GPUpipinstalltorch==1.13.0+cu116--extra-index-urlhttps://download.pytorch.org/whl/cu116
pipinstall-r<(catrequirements.txt|grep-vtorch)pipinstall-rrequirements-dev.txtexportPYTHONPATH=`pwd`pythonscripts/finetune_encdec.py\--model_name_or_patht5-small\--do_train\--do_eval\--train_file./path-to-train.jsonl\--validation_file./path-to-dev.jsonl\--output_dir./tmp-summarization\--per_device_train_batch_size=4\--per_device_eval_batch_size=4\--overwrite_output_dirSupported models are BART, mBART, T5, mT5 and LED.
Only T5 models t5-small, t5-base, t5-large, t5-3b and t5-11b must use an additional argument: --source_prefix "summarize: ".