├── .github ├── ISSUE_TEMPLATE │ ├── bug.yml │ └── feature-request.yml ├── PULL_REQUEST_TEMPLATE.md ├── scripts │ ├── check_copyright_header.py │ ├── markdown_link_check_config.json │ ├── spellcheck.sh │ └── spellcheck_conf │ │ ├── spellcheck.yaml │ │ └── wordlist.txt └── workflows │ ├── pytest_cpu_gha_runner.yaml │ └── spellcheck.yml ├── .gitignore ├── 3p-integrations ├── README.md ├── aws │ ├── getting_started_llama_3_on_amazon_bedrock.ipynb │ ├── prompt_engineering_with_llama_2_on_amazon_bedrock.ipynb │ └── react_llama_3_bedrock_wk.ipynb ├── azure │ ├── Azure MaaS │ │ └── azure_api_example.ipynb │ └── README.md ├── crusoe │ ├── README.md │ └── vllm-fp8 │ │ ├── README.md │ │ ├── assets │ │ ├── tpot_vs_qps_chart.png │ │ └── ttft_vs_qps_chart.png │ │ ├── benchmarks │ │ ├── backend_request_func.py │ │ ├── benchmark_serving.py │ │ └── sonnet.txt │ │ ├── convert_hf_to_fp8.py │ │ ├── main.tf │ │ ├── plot.py │ │ ├── pyproject.toml │ │ └── run_benchmark.sh ├── e2b-ai-analyst │ └── README.md ├── groq │ ├── groq-api-cookbook │ │ ├── function-calling-101-ecommerce │ │ │ ├── Function-Calling-101-Ecommerce.ipynb │ │ │ ├── customers.csv │ │ │ ├── orders.csv │ │ │ └── products.csv │ │ ├── json-mode-function-calling-for-sql │ │ │ ├── data │ │ │ │ ├── employees.csv │ │ │ │ └── purchases.csv │ │ │ ├── json-mode-function-calling-for-sql.ipynb │ │ │ └── verified-queries │ │ │ │ ├── employees-without-purchases.yaml │ │ │ │ ├── most-expensive-purchase.yaml │ │ │ │ ├── most-recent-purchases.yaml │ │ │ │ └── number-of-teslas.yaml │ │ ├── json-mode-social-determinants-of-health │ │ │ ├── SDOH-Json-mode.ipynb │ │ │ └── clinical_notes │ │ │ │ ├── 00456321.txt │ │ │ │ ├── 00567289.txt │ │ │ │ ├── 00678934.txt │ │ │ │ ├── 00785642.txt │ │ │ │ └── 00893247.txt │ │ ├── llama3-stock-market-function-calling │ │ │ └── llama3-stock-market-function-calling.ipynb │ │ ├── parallel-tool-use │ │ │ ├── parallel-tool-use.ipynb │ │ │ └── requirements.txt │ │ └── rag-langchain-presidential-speeches │ │ │ ├── presidential_speeches.csv │ │ │ └── rag-langchain-presidential-speeches.ipynb │ ├── groq-example-templates │ │ ├── conversational-chatbot-langchain │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── crewai-agents │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── groq-quickstart-conversational-chatbot │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── groqing-the-stock-market-function-calling-llama3 │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── llamachat-conversational-chatbot-with-llamaIndex │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── presidential-speeches-rag-with-pinecone │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── text-to-sql-json-mode │ │ │ ├── README.md │ │ │ ├── data │ │ │ │ ├── employees.csv │ │ │ │ └── purchases.csv │ │ │ ├── main.py │ │ │ ├── prompts │ │ │ │ └── base_prompt.txt │ │ │ └── requirements.txt │ │ └── verified-sql-function-calling │ │ │ ├── README.md │ │ │ ├── data │ │ │ ├── employees.csv │ │ │ └── purchases.csv │ │ │ ├── main.py │ │ │ ├── requirements.txt │ │ │ └── verified-queries │ │ │ ├── employees-without-purchases.yaml │ │ │ ├── most-expensive-purchase.yaml │ │ │ ├── most-recent-purchases.yaml │ │ │ └── number-of-teslas.yaml │ └── llama3_cookbook_groq.ipynb ├── lamini │ └── text2sql_memory_tuning │ │ ├── README.md │ │ ├── assets │ │ ├── manual_filtering.png │ │ └── website.png │ │ ├── data │ │ ├── gold-test-set-v2.jsonl │ │ ├── gold-test-set.jsonl │ │ └── training_data │ │ │ ├── archive │ │ │ ├── generated_queries_large_filtered_cleaned.jsonl │ │ │ └── generated_queries_v2_large_filtered_cleaned.jsonl │ │ │ ├── generated_queries.jsonl │ │ │ ├── generated_queries_large.jsonl │ │ │ ├── generated_queries_large_filtered.jsonl │ │ │ ├── generated_queries_v2.jsonl │ │ │ ├── generated_queries_v2_large.jsonl │ │ │ └── generated_queries_v2_large_filtered.jsonl │ │ ├── meta_lamini.ipynb │ │ ├── nba_roster.db │ │ └── util │ │ ├── get_default_finetune_args.py │ │ ├── get_rubric.py │ │ ├── get_schema.py │ │ ├── load_dataset.py │ │ ├── make_llama_3_prompt.py │ │ ├── parse_arguments.py │ │ └── setup_logging.py ├── langchain │ ├── README.md │ ├── langgraph_rag_agent.ipynb │ ├── langgraph_rag_agent_local.ipynb │ └── langgraph_tool_calling_agent.ipynb ├── llama_on_prem.md ├── llamaindex │ ├── dlai_agentic_rag │ │ ├── Building_Agentic_RAG_with_Llamaindex_L2_Tool_Calling.ipynb │ │ ├── Building_Agentic_RAG_with_Llamaindex_L3_Building_an_Agent_Reasoning_Loop.ipynb │ │ ├── Building_Agentic_RAG_with_Llamaindex_L4_Building_a_Multi-Document_Agent.ipynb │ │ └── README.md │ └── llamaindex_cookbook.ipynb ├── modal │ └── many-llamas-human-eval │ │ ├── README.md │ │ ├── download.py │ │ ├── eval.py │ │ ├── generate.py │ │ ├── inference.py │ │ ├── plot.py │ │ └── run_e2e.sh ├── tgi │ ├── README.md │ └── merge_lora_weights.py ├── togetherai │ ├── README.md │ ├── datasets │ │ └── movies.json │ ├── images │ │ ├── BERTScore.png │ │ ├── CoQA.png │ │ ├── ColPaliMaxSim-1.png │ │ ├── Nvidia_collage.png │ │ ├── UMAP.png │ │ ├── cRAG.png │ │ ├── cRAG_indexing.png │ │ ├── cRAG_querytime.png │ │ ├── cluster.png │ │ ├── colpali_arch.png │ │ ├── conversation.png │ │ ├── deploy_CFT.png │ │ ├── ft_model.png │ │ ├── mmrag_only.png │ │ ├── page_25.png │ │ ├── repetition_task.png │ │ ├── reranking.png │ │ ├── semantic_search.png │ │ ├── simple_RAG.png │ │ ├── structured_text_image.png │ │ ├── summarization.png │ │ ├── summary_task.png │ │ ├── text_RAG.png │ │ ├── together-color.jpg │ │ ├── together.gif │ │ └── wandb_model.png │ ├── knowledge_graphs_with_structured_outputs.ipynb │ ├── llama_contextual_RAG.ipynb │ ├── multimodal_RAG_with_nvidia_investor_slide_deck.ipynb │ ├── pdf_to_podcast_using_llama_on_together.ipynb │ ├── structured_text_extraction_from_images.ipynb │ └── text_RAG_using_llama_on_together.ipynb ├── using_externally_hosted_llms.ipynb └── vllm │ ├── README.md │ └── inference.py ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── UPDATES.md ├── dev_requirements.txt ├── end-to-end-use-cases ├── ArticleSummarizer │ ├── .gitignore │ ├── README.md │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle.kts │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── llamaandroiddemo │ │ │ │ ├── AppLog.java │ │ │ │ ├── AppLogging.java │ │ │ │ ├── AppUtils.java │ │ │ │ ├── DemoSharedPreferences.java │ │ │ │ ├── ExampleLlamaRemoteInference.kt │ │ │ │ ├── HomescreenActivity.kt │ │ │ │ ├── LanguageSelector.java │ │ │ │ ├── LogsActivity.java │ │ │ │ ├── LogsAdapter.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── Message.java │ │ │ │ ├── MessageAdapter.java │ │ │ │ ├── MessageType.java │ │ │ │ ├── ModelType.java │ │ │ │ ├── ModelUtils.java │ │ │ │ ├── PromptFormat.java │ │ │ │ ├── SettingsActivity.java │ │ │ │ └── SettingsFields.java │ │ │ └── res │ │ │ ├── drawable │ │ │ ├── banner_shape.xml │ │ │ ├── baseline_add_24.xml │ │ │ ├── baseline_add_photo_alternate_24.xml │ │ │ ├── baseline_article_24.xml │ │ │ ├── baseline_close_24.xml │ │ │ ├── baseline_delete_forever_24.xml │ │ │ ├── baseline_language_24.xml │ │ │ ├── baseline_restart_alt_24.xml │ │ │ ├── baseline_send_24.xml │ │ │ ├── baseline_settings_24.xml │ │ │ ├── baseline_stop_24.xml │ │ │ ├── btn.xml │ │ │ ├── chat_background.xml │ │ │ ├── custom_button_round.xml │ │ │ ├── expand_circle_down.xml │ │ │ ├── ic_launcher_background.xml │ │ │ ├── ic_launcher_foreground.xml │ │ │ ├── input_text_shape.xml │ │ │ ├── outline_add_box_48.xml │ │ │ ├── outline_camera_alt_48.xml │ │ │ ├── outline_image_48.xml │ │ │ ├── prompt_shape.xml │ │ │ ├── received_message.xml │ │ │ ├── sent_message.xml │ │ │ ├── summarizer.png │ │ │ └── three_dots.xml │ │ │ ├── layout │ │ │ ├── activity_benchmarking.xml │ │ │ ├── activity_homescreen.xml │ │ │ ├── activity_logs.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_settings.xml │ │ │ ├── logs_message.xml │ │ │ ├── received_message.xml │ │ │ ├── sent_message.xml │ │ │ └── system_message.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ ├── styles.xml │ │ │ └── themes.xml │ │ │ └── xml │ │ │ ├── backup_rules.xml │ │ │ ├── data_extraction_rules.xml │ │ │ └── file_paths.xml │ ├── build.gradle.kts │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── screenshot.png │ └── settings.gradle.kts ├── Contextual-Chunking-RAG │ ├── Example_FinancialReport_RAG.ipynb │ ├── README.md │ ├── Tutorial.ipynb │ ├── config.py │ ├── data │ │ └── llama_article.txt │ ├── embedding.py │ └── helper.py ├── Multi-Modal-RAG │ ├── README.md │ ├── notebooks │ │ ├── Part_1_Data_Preparation.ipynb │ │ ├── Part_2_Cleaning_Data_and_DB.ipynb │ │ └── Part_3_RAG_Setup_and_Validation.ipynb │ └── scripts │ │ ├── final_demo.py │ │ └── label_script.py ├── NotebookLlama │ ├── README.md │ ├── Step-1 PDF-Pre-Processing-Logic.ipynb │ ├── Step-2-Transcript-Writer.ipynb │ ├── Step-3-Re-Writer.ipynb │ ├── Step-4-TTS-Workflow.ipynb │ ├── TTS_Notes.md │ ├── requirements.txt │ └── resources │ │ ├── 2402.13116v4.pdf │ │ ├── Outline.jpg │ │ ├── _podcast.mp3 │ │ ├── clean_extracted_text.txt │ │ ├── data.pkl │ │ └── podcast_ready_data.pkl ├── RAFT-Chatbot │ ├── README.md │ ├── config.py │ ├── eval_llama.json │ ├── format.py │ ├── images │ │ ├── Answers_Precision.png │ │ ├── LLM_score_comparison.png │ │ ├── Num_of_refusal_comparison.png │ │ └── RAFT.png │ ├── raft.py │ ├── raft.yaml │ ├── raft_eval.py │ ├── raft_eval_config.yaml │ └── raft_utils.py ├── README.md ├── agents │ ├── Agents_Tutorial │ │ ├── Tool_Calling_101.ipynb │ │ └── Tool_Calling_201.ipynb │ ├── DeepLearningai_Course_Notebooks │ │ ├── AI_Agentic_Design_Patterns_with_AutoGen_L4_Tool_Use_and_Conversational_Chess.ipynb │ │ ├── AI_Agents_in_LangGraph_L1_Build_an_Agent_from_Scratch.ipynb │ │ ├── Building_Agentic_RAG_with_Llamaindex_L1_Router_Engine.ipynb │ │ ├── Functions_Tools_and_Agents_with_LangChain_L1_Function_Calling.ipynb │ │ └── README.md │ ├── README.md │ └── calendar_assistant │ │ ├── README.md │ │ ├── assets │ │ ├── flow_diagram.png │ │ └── google_calendar.png │ │ └── tool_calling_google_api.ipynb ├── benchmarks │ ├── README.md │ ├── evals_synthetic_data │ │ ├── README.md │ │ ├── Workflow_Diagram.png │ │ ├── evals_with_synthetic_data.ipynb │ │ └── generated_data │ │ │ ├── data_0.json │ │ │ ├── data_1.json │ │ │ ├── data_10.json │ │ │ ├── data_11.json │ │ │ ├── data_2.json │ │ │ ├── data_3.json │ │ │ ├── data_4.json │ │ │ ├── data_5.json │ │ │ ├── data_6.json │ │ │ ├── data_7.json │ │ │ ├── data_8.json │ │ │ ├── data_9.json │ │ │ └── tabular_data.csv │ ├── inference │ │ ├── README.md │ │ ├── cloud │ │ │ ├── README.md │ │ │ ├── aws │ │ │ │ └── fmbench │ │ │ │ │ ├── README.md │ │ │ │ │ ├── config.yml │ │ │ │ │ └── img │ │ │ │ │ ├── CFT.png │ │ │ │ │ ├── business_summary.png │ │ │ │ │ ├── instances.png │ │ │ │ │ └── latency_vs_tokens.png │ │ │ └── azure │ │ │ │ ├── chat_azure_api_benchmark.py │ │ │ │ ├── input.jsonl │ │ │ │ ├── parameters.json │ │ │ │ └── pretrained_azure_api_benchmark.py │ │ ├── on_prem │ │ │ ├── README.md │ │ │ └── vllm │ │ │ │ ├── chat_vllm_benchmark.py │ │ │ │ ├── input.jsonl │ │ │ │ ├── parameters.json │ │ │ │ └── pretrained_vllm_benchmark.py │ │ └── requirements.txt │ └── llm_eval_harness │ │ ├── README.md │ │ └── meta_eval │ │ ├── README.md │ │ ├── eval_config.yaml │ │ ├── meta_template │ │ ├── bbh │ │ │ ├── bbh_3shot_cot.yaml │ │ │ └── utils.py │ │ ├── gpqa │ │ │ ├── gpqa_0shot.yaml │ │ │ └── utils.py │ │ ├── gpqa_cot │ │ │ ├── gpqa_0shot_cot.yaml │ │ │ └── utils.py │ │ ├── ifeval │ │ │ ├── ifeval.yaml │ │ │ └── utils.py │ │ ├── math_hard │ │ │ ├── math_4shot_cot.yaml │ │ │ ├── math_hard_0shot_cot.yaml │ │ │ └── utils.py │ │ ├── meta_instruct.yaml │ │ ├── meta_pretrain.yaml │ │ ├── mmlu │ │ │ ├── mmlu_instruct.yaml │ │ │ ├── mmlu_pretrain.yaml │ │ │ └── utils.py │ │ └── mmlu_pro │ │ │ ├── mmlu_pro_5shot_cot_instruct.yaml │ │ │ ├── mmlu_pro_5shot_cot_pretrain.yaml │ │ │ └── utils.py │ │ └── prepare_meta_eval.py ├── book-character-mindmap │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── character_relationship.png │ │ ├── chat_interface.png │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ ├── mindmap.png │ │ └── robots.txt │ ├── server │ │ ├── requirements.txt │ │ └── server.py │ ├── src │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── approuter.jsx │ │ ├── index.css │ │ ├── index.js │ │ ├── logo.svg │ │ ├── pages │ │ │ ├── Layout.jsx │ │ │ ├── bookPage │ │ │ │ ├── components │ │ │ │ │ ├── CharacterGraph.jsx │ │ │ │ │ ├── ChatInterface.jsx │ │ │ │ │ └── ErrorBoundary.jsx │ │ │ │ └── index.jsx │ │ │ └── homePage │ │ │ │ ├── components │ │ │ │ ├── Features.jsx │ │ │ │ ├── Hero.jsx │ │ │ │ └── HowItWorks.jsx │ │ │ │ └── index.jsx │ │ ├── reportWebVitals.js │ │ └── setupTests.js │ └── tailwind.config.js ├── browser_use │ ├── README.md │ └── agent │ │ ├── browser-use-quickstart.ipynb │ │ └── sample_screenshot.png ├── coding │ └── text2sql │ │ ├── README.md │ │ ├── csv2db.py │ │ ├── nba.txt │ │ ├── nba_roster.db │ │ ├── quickstart.ipynb │ │ ├── requirements.txt │ │ └── txt2csv.py ├── customerservice_chatbots │ ├── RAG_chatbot │ │ ├── RAG_Chatbot_Example.ipynb │ │ ├── data │ │ │ └── Llama Getting Started Guide.pdf │ │ ├── requirements.txt │ │ └── vectorstore │ │ │ ├── db_faiss │ │ │ ├── index.faiss │ │ │ └── index.pkl │ │ │ └── mongodb │ │ │ └── rag_mongodb_llama3_huggingface_open_source.ipynb │ ├── README.md │ ├── messenger_chatbot │ │ ├── llama_messenger.py │ │ └── messenger_llama3.md │ └── whatsapp_chatbot │ │ ├── llama_chatbot.py │ │ └── whatsapp_llama3.md ├── email_agent │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── README.md │ ├── email_agent.png │ ├── email_agent.py │ ├── functions_prompt.py │ ├── main.py │ └── requirements.txt ├── github_triage │ ├── README.md │ ├── config.yaml │ ├── llm.py │ ├── output │ │ └── pytorch │ │ │ └── pytorch │ │ │ └── 2024-08-28_2024-08-28 │ │ │ ├── annotated_issues.csv │ │ │ ├── challenges.csv │ │ │ ├── overview.csv │ │ │ ├── plots │ │ │ ├── commits.png │ │ │ ├── engagement_sankey.png │ │ │ ├── expertise.png │ │ │ ├── sentiment.png │ │ │ ├── severity.png │ │ │ └── themes.png │ │ │ └── report.pdf │ ├── pdf_report.py │ ├── plots.py │ ├── requirements.txt │ ├── triage.py │ ├── utils.py │ └── walkthrough.ipynb ├── long_context │ └── H2O │ │ ├── README.md │ │ ├── data │ │ └── summarization │ │ │ ├── cnn_dailymail.jsonl │ │ │ └── xsum.jsonl │ │ ├── requirements.txt │ │ ├── run_streaming.py │ │ ├── run_summarization.py │ │ ├── src │ │ └── streaming.sh │ │ └── utils │ │ ├── cache.py │ │ ├── llama.py │ │ └── streaming.py ├── multilingual │ ├── README.md │ ├── extend_tokenizer.py │ ├── img │ │ ├── phase1_eval_loss.png │ │ ├── phase1_train_loss.png │ │ ├── phase2_eval_loss.png │ │ └── phase2_train_loss.png │ ├── prepare_data.py │ └── train_tokenizer.py ├── research_paper_analyzer │ ├── README.md │ ├── requirements.txt │ └── research_analyzer.py ├── video_summary.ipynb └── whatsapp_llama_4_bot │ ├── .env │ ├── README.md │ ├── ec2_endpoints.py │ ├── ec2_services.py │ ├── requirements.txt │ ├── webhook_main.py │ └── webhook_utils.py ├── getting-started ├── RAG │ └── hello_llama_cloud.ipynb ├── README.md ├── build_with_llama_4.ipynb ├── build_with_llama_api.ipynb ├── finetuning │ ├── LLM_finetuning_overview.md │ ├── README.md │ ├── datasets │ │ ├── README.md │ │ ├── custom_dataset.py │ │ ├── ocrvqa_dataset.py │ │ └── raft_dataset.py │ ├── finetune_llama4.md │ ├── finetune_vision_model.md │ ├── finetuning.py │ ├── multi_node.slurm │ ├── multigpu_finetuning.md │ ├── quickstart_peft_finetuning.ipynb │ └── singlegpu_finetuning.md ├── inference │ ├── README.md │ ├── api_inference │ │ ├── README.md │ │ ├── api_inference.py │ │ └── llama_inference_api.ipynb │ └── local_inference │ │ ├── README.md │ │ ├── chat_completion │ │ ├── chat_completion.py │ │ └── chats.json │ │ ├── inference.py │ │ ├── multi_modal_infer.py │ │ └── samsum_prompt.txt ├── llama-tools │ └── llama-prompt-ops_101.ipynb └── responsible_ai │ ├── README.md │ ├── code_shield_usage_demo.ipynb │ ├── llama_guard │ ├── README.md │ ├── __init__.py │ ├── llama_guard_customization_via_prompting_and_fine_tuning.ipynb │ ├── llama_guard_finetuning_multiple_violations_with_torchtune.ipynb │ ├── llama_guard_text_and_vision_inference.ipynb │ ├── resources │ │ ├── dog.jpg │ │ └── pasta.jpeg │ └── torchtune_configs │ │ ├── 8B_guard_full.yaml │ │ └── custom_template.py │ └── prompt_guard │ ├── README.md │ ├── __init__.py │ ├── inference.py │ ├── prompt_guard_1_inference.py │ └── prompt_guard_tutorial.ipynb ├── pyproject.toml ├── requirements.txt └── src ├── README.md ├── docs ├── FAQ.md ├── LLM_finetuning.md ├── img │ ├── WhatApp_Llama4_integration.jpeg │ ├── a_colorful_llama_doing_ai_programming.jpeg │ ├── a_llama_dressed_as_a_professional_mountain.jpeg │ ├── cat.jpeg │ ├── feature_based_fn.png │ ├── feature_based_fn_2.png │ ├── full_param_fn.png │ ├── gnocchi_alla_romana.jpeg │ ├── grocery_shopping_bascket_with_salmon_in_package.jpeg │ ├── k1.jpg │ ├── k1_resized.jpg │ ├── k2.jpg │ ├── k2_resized.jpg │ ├── k3.jpg │ ├── k3_resized.jpg │ ├── k4.jpg │ ├── k4_resized.jpg │ ├── llama-mobile-confirmed.png │ ├── llama-recipes.png │ ├── llama2_gradio.png │ ├── llama2_streamlit.png │ ├── llama2_streamlit2.png │ ├── llama_stack.png │ ├── messenger_api_settings.png │ ├── messenger_llama_arch.jpg │ ├── meta_release.png │ ├── resized_image.jpg │ ├── thumbnail_IMG_1329.jpg │ ├── thumbnail_IMG_1440.jpg │ ├── thumbnail_IMG_6385.jpg │ ├── wandb_screenshot.png │ ├── whatsapp_dashboard.jpg │ └── whatsapp_llama_arch.jpg ├── multi_gpu.md └── single_gpu.md ├── llama_cookbook ├── configs │ ├── __init__.py │ ├── datasets.py │ ├── fsdp.py │ ├── peft.py │ ├── quantization.py │ ├── training.py │ └── wandb.py ├── data │ ├── __init__.py │ ├── concatenator.py │ ├── llama_guard │ │ ├── README.md │ │ ├── __init__.py │ │ ├── finetuning_data_formatter.py │ │ └── finetuning_data_formatter_example.py │ └── sampler.py ├── datasets │ ├── __init__.py │ ├── alpaca_dataset.py │ ├── custom_dataset.py │ ├── grammar_dataset │ │ ├── __init__.py │ │ ├── grammar_dataset.py │ │ └── grammar_dataset_process.ipynb │ ├── samsum_dataset.py │ └── toxicchat_dataset.py ├── finetuning.py ├── inference │ ├── __init__.py │ ├── chat_utils.py │ ├── checkpoint_converter_fsdp_hf.py │ ├── llm.py │ ├── model_utils.py │ ├── prompt_format_utils.py │ └── safety_utils.py ├── model_checkpointing │ ├── __init__.py │ └── checkpoint_handler.py ├── policies │ ├── __init__.py │ ├── activation_checkpointing_functions.py │ ├── anyprecision_optimizer.py │ ├── mixed_precision.py │ └── wrapping.py ├── tools │ ├── README.md │ ├── compare_llama_weights.py │ └── convert_hf_weights_to_llama.py └── utils │ ├── __init__.py │ ├── config_utils.py │ ├── dataset_utils.py │ ├── flop_utils.py │ ├── fsdp_utils.py │ ├── memory_utils.py │ ├── plot_metrics.py │ └── train_utils.py └── tests ├── conftest.py ├── datasets ├── test_custom_dataset.py ├── test_grammar_datasets.py └── test_samsum_datasets.py ├── test_batching.py ├── test_chat_completion.py ├── test_finetuning.py ├── test_finetuning_data_formatter.py ├── test_sampler.py ├── test_train_utils.py └── utils.py /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: 🚀 Feature request 2 | description: Submit a proposal/request for a new llama-cookbook feature 3 | 4 | body: 5 | - type: textarea 6 | id: feature-pitch 7 | attributes: 8 | label: 🚀 The feature, motivation and pitch 9 | description: > 10 | A clear and concise description of the feature proposal. Please outline the motivation for the proposal. Is your feature request related to a specific problem? e.g., *"I'm working on X and would like Y to be possible"*. If this is related to another GitHub issue, please link here too. 11 | validations: 12 | required: true 13 | 14 | - type: textarea 15 | id: alternatives 16 | attributes: 17 | label: Alternatives 18 | description: > 19 | A description of any alternative solutions or features you've considered, if any. 20 | 21 | - type: textarea 22 | id: additional-context 23 | attributes: 24 | label: Additional context 25 | description: > 26 | Add any other context or screenshots about the feature request. 27 | 28 | - type: markdown 29 | attributes: 30 | value: > 31 | Thanks for contributing 🎉! -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # What does this PR do? 2 | 3 | 11 | 12 | 13 | 14 | Fixes # (issue) 15 | 16 | 17 | ## Feature/Issue validation/testing 18 | 19 | Please describe the tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced. 20 | Please also list any relevant details for your test configuration. 21 | 22 | - [ ] Test A 23 | Logs for Test A 24 | 25 | - [ ] Test B 26 | Logs for Test B 27 | 28 | 29 | ## Before submitting 30 | - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). 31 | - [ ] Did you read the [contributor guideline](https://github.com/meta-llama/llama-cookbook/blob/main/CONTRIBUTING.md), 32 | Pull Request section? 33 | - [ ] Was this discussed/approved via a Github issue? Please add a link 34 | to it if that's the case. 35 | - [ ] Did you make sure to update the documentation with your changes? 36 | - [ ] Did you write any new necessary tests? 37 | 38 | Thanks for contributing 🎉! 39 | -------------------------------------------------------------------------------- /.github/scripts/check_copyright_header.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement. 3 | 4 | import re 5 | from pathlib import Path 6 | 7 | WORK_DIR = Path(__file__).parents[1] 8 | PATTERN = "(Meta Platforms, Inc. and affiliates)|(Facebook, Inc(\.|,)? and its affiliates)|([0-9]{4}-present(\.|,)? Facebook)|([0-9]{4}(\.|,)? Facebook)" 9 | 10 | HEADER = """# Copyright (c) Meta Platforms, Inc. and affiliates. 11 | # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.\n\n""" 12 | 13 | #Files in black list must be relative to main repo folder 14 | BLACKLIST = ["tools/benchmarks/llm_eval_harness/open_llm_leaderboard/hellaswag_utils.py"] 15 | 16 | if __name__ == "__main__": 17 | for ext in ["*.py", "*.sh"]: 18 | for file in WORK_DIR.rglob(ext): 19 | normalized = file.relative_to(WORK_DIR) 20 | if normalized.as_posix() in BLACKLIST: 21 | continue 22 | 23 | text = file.read_text() 24 | if not re.search(PATTERN, text): 25 | text = HEADER + text 26 | file.write_text(text) 27 | -------------------------------------------------------------------------------- /.github/scripts/markdown_link_check_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "retryOn429": true, 3 | "retryCount": 5, 4 | "fallbackRetryDelay": "10s", 5 | "httpHeaders": [ 6 | { 7 | "urls": [ 8 | "https://docs.github.com/", 9 | "https://help.github.com/" 10 | ], 11 | "headers": { 12 | "Accept-Encoding": "zstd, br, gzip, deflate" 13 | } 14 | } 15 | ], 16 | "ignorePatterns": [ 17 | { 18 | "pattern": "^http(s)?://127.0.0.1.*" 19 | }, 20 | { 21 | "pattern": "^http(s)?://localhost.*" 22 | }, 23 | { 24 | "pattern": "https://www.intel.com/content/www/us/en/developer/articles/news/llama2.html" 25 | }, 26 | { 27 | "pattern": "http(s.?)?:\/\/(www\.)?linkedin\.com\.*" 28 | }, 29 | { 30 | "pattern": "http(s?)?:\/\/(www\.)?medium\.com\/.*" 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /.github/scripts/spellcheck.sh: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement. 4 | # Source: https://github.com/pytorch/torchx/blob/main/scripts/spellcheck.sh 5 | set -ex 6 | sudo apt-get install aspell 7 | 8 | if [[ -z "$@" ]]; then 9 | sources=$(find -name '*.md') 10 | else 11 | sources=$@ 12 | fi 13 | 14 | sources_arg="" 15 | for src in $sources; do 16 | sources_arg="${sources_arg} -S $src" 17 | done 18 | 19 | if [ ! "$sources_arg" ]; then 20 | echo "No files to spellcheck" 21 | else 22 | pyspelling -c .github/scripts/spellcheck_conf/spellcheck.yaml --name Markdown $sources_arg 23 | fi 24 | -------------------------------------------------------------------------------- /.github/scripts/spellcheck_conf/spellcheck.yaml: -------------------------------------------------------------------------------- 1 | matrix: 2 | - name: Markdown 3 | apsell: 4 | lang: en 5 | d: en_US 6 | dictionary: 7 | wordlists: 8 | - .github/scripts/spellcheck_conf/wordlist.txt 9 | output: .github/scripts/spellcheck_conf/wordlist.dic 10 | encoding: utf-8 11 | pipeline: 12 | - pyspelling.filters.context: 13 | context_visible_first: true 14 | delimiters: 15 | - open: '(?s)^ *(?P`{3,})[a-z0-9]*?$' 16 | close: '^(?P=open)$' 17 | - open: '' 18 | content: 'https?://[-a-zA-Z0-9.]+?\.[a-z]{2,6}[-?=&%.0-9a-zA-Z/_#]*' 19 | close: '' 20 | - pyspelling.filters.markdown: 21 | markdown_extensions: 22 | - markdown.extensions.extra: 23 | -------------------------------------------------------------------------------- /.github/workflows/spellcheck.yml: -------------------------------------------------------------------------------- 1 | name: SpellCheck 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | jobs: 11 | build: 12 | runs-on: ubuntu-24.04 13 | name: Lint changed files 14 | steps: 15 | - uses: actions/checkout@v3 16 | with: 17 | fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. 18 | 19 | - name: Check links in all markdown files 20 | uses: gaurav-nelson/github-action-markdown-link-check@1.0.13 21 | with: 22 | use-verbose-mode: 'yes' 23 | config-file: ".github/scripts/markdown_link_check_config.json" 24 | 25 | - name: Get changed files 26 | id: changed-files 27 | uses: tj-actions/changed-files@v45.0.8 28 | with: 29 | 30 | files: | 31 | **/*.py 32 | 33 | spellcheck: 34 | runs-on: ubuntu-24.04 35 | steps: 36 | - uses: actions/checkout@v3 37 | 38 | - name: Install dependencies 39 | run: | 40 | sudo apt-get install aspell aspell-en 41 | pip install pyspelling 42 | 43 | - name: Get changed files 44 | id: changed-files 45 | uses: tj-actions/changed-files@v45.0.8 46 | with: 47 | files: | 48 | **/*.md 49 | 50 | - name: Check spellings 51 | run: | 52 | sources="" 53 | for file in ${{ steps.changed-files.outputs.all_changed_files }}; do 54 | sources="${sources} -S $file" 55 | done 56 | if [ ! "$sources" ]; then 57 | echo "No files to spellcheck" 58 | else 59 | pyspelling -c $GITHUB_WORKSPACE/.github/scripts/spellcheck_conf/spellcheck.yaml --name Markdown $sources 60 | fi 61 | 62 | - name: In the case of misspellings 63 | if: ${{ failure() }} 64 | run: | 65 | echo "Please fix the misspellings. If you are sure about some of them, " 66 | echo "so append those to .github/scripts/spellcheck_conf/wordlist.txt" 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | __pycache__ 3 | .ipynb_checkpoints 4 | wandb/ 5 | artifacts/ 6 | node_modules/ 7 | -------------------------------------------------------------------------------- /3p-integrations/azure/README.md: -------------------------------------------------------------------------------- 1 | In this folder, we show various recipes for Llama models working with Azure AI services. This includes: 2 | * Examples for running Llama model inference on Azure's serverless API offerings (aka. MaaS) 3 | -------------------------------------------------------------------------------- /3p-integrations/crusoe/README.md: -------------------------------------------------------------------------------- 1 | Below are recipes for deploying common Llama workflows on [Crusoe's](https://crusoe.ai) high-performance, sustainable cloud. Each workflow corresponds to a subfolder with its own README and supplemental materials. Please reference the table below for hardware requirements. 2 | 3 | | Workflow | Model(s) | VM type | Storage | 4 | |:----: | :----: | :----:| :----: | 5 | | [Serving Llama3.1 in FP8 with vLLM](vllm-fp8/) | [meta-llama/Meta-Llama-3.1-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct), [meta-llama/Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct) | l40s-48gb.8x | 256 GiB Persistent Disk | 6 | 7 | # Requirements 8 | First, ensure that you have a Crusoe account (you can sign up [here](https://console.crusoecloud.com/)). We will provision resources using Terraform, please ensure that your environment is configured and refer to the Crusoe [docs](https://github.com/crusoecloud/terraform-provider-crusoe?tab=readme-ov-file#getting-started) for guidance. 9 | 10 | # Serving Models 11 | Some recipes in this repo require firewall rules to expose ports in order to reach the inference server. To manage firewall rules, please refer to our [networking documentation](https://docs.crusoecloud.com/networking/firewall-rules/managing-firewall-rules). 12 | -------------------------------------------------------------------------------- /3p-integrations/crusoe/vllm-fp8/assets/tpot_vs_qps_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/crusoe/vllm-fp8/assets/tpot_vs_qps_chart.png -------------------------------------------------------------------------------- /3p-integrations/crusoe/vllm-fp8/assets/ttft_vs_qps_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/crusoe/vllm-fp8/assets/ttft_vs_qps_chart.png -------------------------------------------------------------------------------- /3p-integrations/crusoe/vllm-fp8/main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | crusoe = { 4 | source = "registry.terraform.io/crusoecloud/crusoe" 5 | } 6 | } 7 | } 8 | 9 | locals { 10 | my_ssh_key = file("~/.ssh/id_ed25519.pub") 11 | } 12 | 13 | // new VM 14 | resource "crusoe_compute_instance" "vllm_vm" { 15 | name = "vllm-example" 16 | type = "l40s-48gb.8x" 17 | location = "us-southcentral1-a" 18 | 19 | # specify the base image 20 | image = "ubuntu22.04-nvidia-slurm:12.4" 21 | 22 | disks = [ 23 | { 24 | id = crusoe_storage_disk.vllm_data_disk.id 25 | mode = "read-write" 26 | attachment_type = "data" 27 | } 28 | ] 29 | 30 | ssh_key = local.my_ssh_key 31 | } 32 | 33 | resource "crusoe_storage_disk" "vllm_data_disk" { 34 | name = "vllm-example-disk" 35 | size = "256GiB" 36 | location = "us-southcentral1-a" 37 | } 38 | 39 | output "instance_public_ip" { 40 | value = crusoe_compute_instance.vllm_vm.network_interfaces[0].public_ipv4.address 41 | } 42 | -------------------------------------------------------------------------------- /3p-integrations/crusoe/vllm-fp8/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "vllm-l40s" 3 | version = "0.1.0" 4 | description = "Add your description here" 5 | readme = "README.md" 6 | requires-python = ">=3.10" 7 | dependencies = [ 8 | "setuptools>=74.0.0", 9 | "vllm>=0.5.5", 10 | "matplotlib>=3.9.2", 11 | "llmcompressor>=0.1.0", 12 | ] 13 | -------------------------------------------------------------------------------- /3p-integrations/crusoe/vllm-fp8/run_benchmark.sh: -------------------------------------------------------------------------------- 1 | TOTAL_SECONDS=120 2 | QPS_RATES=("1" "3" "5" "7" "9") 3 | 4 | for QPS in ${QPS_RATES[@]}; do 5 | NUM_PROMPTS=$((TOTAL_SECONDS * QPS)) 6 | echo "===== RUNNING NUM_PROMPTS = $NUM_PROMPTS QPS = $QPS =====" 7 | 8 | uv run benchmarks/benchmark_serving.py \ 9 | --model $MODEL \ 10 | --dataset-name sonnet --sonnet-input-len 550 --sonnet-output-len 150 --dataset-path benchmarks/sonnet.txt \ 11 | --num-prompts $NUM_PROMPTS --request-rate $QPS --save-result 12 | done -------------------------------------------------------------------------------- /3p-integrations/e2b-ai-analyst/README.md: -------------------------------------------------------------------------------- 1 | # AI Analyst with Llama and E2B 2 | This is an AI-powered code and data analysis tool powered by Meta Llama and the [E2B SDK](https://e2b.dev/docs). 3 | 4 | → Try on [ai-analyst.e2b.dev](https://ai-analyst.e2b.dev/) 5 | 6 | ## Features 7 | - 🔸 Analyze data with Meta's Llama 3.1 and 3.2 8 | - 🔸 Upload CSV files 9 | - 🔸 Create interactive charts 10 | 11 | **Powered by:** 12 | 13 | - 🔸 ✶ [E2B Sandbox](https://github.com/e2b-dev/code-interpreter) 14 | - 🔸 Vercel's AI SDK 15 | - 🔸 Next.js 16 | - 🔸 echarts library for interactive charts 17 | 18 | **Supported LLM Providers:** 19 | - 🔸 TogetherAI 20 | - 🔸 Fireworks 21 | - 🔸 Ollama 22 | 23 | **Supported chart types:** 24 | - 🔸 All the supported charts are described [here](https://e2b.dev/docs/code-interpreting/create-charts-visualizations/interactive-charts#supported-intertactive-charts). 25 | 26 | 27 | ## Get started 28 | 29 | Visit the [online version](https://ai-analyst.e2b.dev/) or run locally on your own. 30 | 31 | ### 1. Clone repository 32 | ``` 33 | git clone https://github.com/e2b-dev/ai-analyst.git 34 | ``` 35 | 36 | ### 2. Install dependencies 37 | ``` 38 | cd ai-analyst && npm i 39 | ``` 40 | 41 | ### 3. Add E2B API key 42 | Copy `.example.env` to `.env.local` and fill in `E2B_API_KEY`. 43 | 44 | - Get your [E2B API key here](https://e2b.dev/dashboard?tab=keys). 45 | 46 | ### 4. Configure LLM provider 47 | 48 | In `.env.local`, add an API key for at least one LLM provider: 49 | 50 | - Fireworks: `FIREWORKS_API_KEY` 51 | - Together AI: `TOGETHER_API_KEY` 52 | 53 | For Ollama, provide the base URL instead of the API key: 54 | 55 | - Ollama: `OLLAMA_BASE_URL` 56 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/function-calling-101-ecommerce/customers.csv: -------------------------------------------------------------------------------- 1 | customer_id,name,email,address 2 | 1,Erin Boyle MD,erin.boyle.md@example.com,"165 Brown Springs 3 | Michaelport, IL 60228" 4 | 2,Matthew Saunders,matthew.saunders@example.com,"219 Steven Mountains 5 | Port Gabriellafort, OH 52281" 6 | 3,Amanda Anderson,amanda.anderson@example.com,"498 Laurie Glens 7 | Mitchelltown, CT 93655" 8 | 4,Julian Butler,julian.butler@example.com,"909 Rodriguez Harbors Suite 119 9 | New Tracyburgh, MS 15487" 10 | 5,Zachary Mitchell MD,zachary.mitchell.md@example.com,"9087 Matthew Drives 11 | Caitlynshire, OR 42442" 12 | 6,Troy Bennett,troy.bennett@example.com,"73329 Kimberly Loaf Apt. 029 13 | Shellyborough, TX 55939" 14 | 7,Allison Hall,allison.hall@example.com,"210 Shannon Camp 15 | New Michael, MO 65990" 16 | 8,Carolyn Davis,carolyn.davis@example.com,"64228 Carol Courts Suite 087 17 | New Micheleshire, MT 42516" 18 | 9,Cindy Munoz,cindy.munoz@example.com,"1722 Christine Plaza 19 | Danielport, UT 12261" 20 | 10,Tom Testuser,tom.testuser@example.com,"451 Victoria Bridge Suite 529 21 | Pageton, WI 27404" 22 | 11,Charles Walker,charles.walker@example.com,"2077 Lamb Drive 23 | Salazarton, IN 54619" 24 | 12,Brianna Molina,brianna.molina@example.com,"586 Khan Mills Suite 202 25 | Lake Dominique, VA 98527" 26 | 13,Austin Andrade,austin.andrade@example.com,"4857 Donna Cliffs 27 | Floydstad, PR 82540" 28 | 14,Brandon Andrade,brandon.andrade@example.com,"906 Olivia Motorway 29 | Kelleyfort, AK 48960" 30 | 15,Diane Lam,diane.lam@example.com,"070 Eric Rapid Suite 159 31 | Townsendbury, MI 57664" 32 | 16,Jason Kelly,jason.kelly@example.com,"873 Angela Track Apt. 972 33 | Stephenville, NV 32705" 34 | 17,Mr. Mitchell Saunders,mr..mitchell.saunders@example.com,"USS White 35 | FPO AE 91058" 36 | 18,Regina Ross,regina.ross@example.com,"91857 Wendy Place 37 | East Charlesshire, CA 43705" 38 | 19,Mrs. Denise May DDS,mrs..denise.may.dds@example.com,"64590 Kathleen Cove Apt. 736 39 | Derrickton, AK 05935" 40 | 20,Lisa Boyle,lisa.boyle@example.com,"USNS Russell 41 | FPO AE 51528" 42 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/function-calling-101-ecommerce/orders.csv: -------------------------------------------------------------------------------- 1 | order_id,product_id,customer_id,order_date 2 | 1,13,18,2024-02-15 15:15 3 | 2,19,6,2024-01-03 17:43 4 | 3,12,20,2024-03-11 1:13 5 | 4,7,20,2024-02-04 12:04 6 | 5,14,3,2024-05-02 17:12 7 | 6,17,6,2024-02-12 1:46 8 | 7,20,4,2024-02-26 2:59 9 | 8,4,7,2024-05-02 16:51 10 | 9,11,2,2024-01-04 11:09 11 | 10,6,9,2024-04-09 15:04 12 | 11,3,7,2024-02-21 21:17 13 | 12,6,18,2024-02-21 18:50 14 | 13,17,11,2024-05-02 16:20 15 | 14,11,15,2024-04-20 2:49 16 | 15,16,7,2024-01-18 1:12 17 | 16,16,16,2024-05-03 11:20 18 | 17,14,18,2024-03-26 22:51 19 | 18,20,16,2024-05-07 23:25 20 | 19,1,12,2024-05-20 12:41 21 | 20,20,3,2024-01-17 7:25 -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/function-calling-101-ecommerce/products.csv: -------------------------------------------------------------------------------- 1 | product_id,name,description,price,stock_quantity 2 | 1,Laptop,High performance laptop with 16GB RAM and 512GB SSD.,753.03,15 3 | 2,Smartphone,Latest model smartphone with a stunning display and great camera.,398.54,59 4 | 3,Headphones,Noise-cancelling over-ear headphones with long battery life.,889.79,97 5 | 4,Monitor,24-inch 1080p monitor with vibrant colors and wide viewing angles.,604.44,98 6 | 5,Keyboard,Mechanical keyboard with customizable RGB lighting.,500.24,52 7 | 6,Mouse,Wireless mouse with ergonomic design and long battery life.,321.98,57 8 | 7,Printer,All-in-one printer with wireless connectivity and high-quality printing.,695.29,32 9 | 8,Tablet,Portable tablet with 10-inch display and powerful processor.,625.75,28 10 | 9,Smartwatch,Stylish smartwatch with fitness tracking and notifications.,952.72,42 11 | 10,Camera,Digital camera with 20MP sensor and 4K video recording.,247.93,99 12 | 11,Speaker,Bluetooth speaker with excellent sound quality and deep bass.,896.4,32 13 | 12,Router,Wi-Fi router with high speed and wide coverage.,976.16,59 14 | 13,External Hard Drive,1TB external hard drive with fast data transfer speeds.,434.46,18 15 | 14,USB Flash Drive,64GB USB flash drive with compact design and reliable storage.,991.09,77 16 | 15,Microphone,Professional microphone with clear sound and adjustable settings.,276.23,30 17 | 16,Webcam,HD webcam with wide-angle lens and built-in microphone.,890.39,13 18 | 17,Drone,Compact drone with HD camera and stable flight controls.,285.93,37 19 | 18,Projector,Portable projector with bright display and multiple connectivity options.,290.22,31 20 | 19,Fitness Tracker,Fitness tracker with heart rate monitor and sleep tracking.,953.65,4 21 | 20,E-Reader,Lightweight e-reader with high-resolution display and long battery life.,132.15,62 22 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/json-mode-function-calling-for-sql/data/employees.csv: -------------------------------------------------------------------------------- 1 | employee_id,name,email 2 | 1,Richard Hendricks,richard@piedpiper.com 3 | 2,Erlich Bachman,erlich@aviato.com 4 | 3,Dinesh Chugtai,dinesh@piedpiper.com 5 | 4,Bertram Gilfoyle,gilfoyle@piedpiper.com 6 | 5,Jared Dunn,jared@piedpiper.com 7 | 6,Monica Hall,monica@raviga.com 8 | 7,Gavin Belson,gavin@hooli.com -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/json-mode-function-calling-for-sql/data/purchases.csv: -------------------------------------------------------------------------------- 1 | purchase_id,purchase_date,product_name,employee_id,amount 2 | 1,'2024-02-01',iPhone,1,750 3 | 2,'2024-02-02',Tesla,2,70000 4 | 3,'2024-02-03',Humane pin,3,500 5 | 4,'2024-02-04',iPhone,4,700 6 | 5,'2024-02-05',Tesla,5,75000 -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/json-mode-function-calling-for-sql/verified-queries/employees-without-purchases.yaml: -------------------------------------------------------------------------------- 1 | description: Employees without a purchase since Feb 1, 2024 2 | sql: | 3 | SELECT employees.name as employees_without_purchases 4 | FROM employees.csv AS employees 5 | LEFT JOIN purchases.csv AS purchases ON employees.employee_id = purchases.employee_id 6 | AND purchases.purchase_date > '2024-02-01' 7 | WHERE purchases.purchase_id IS NULL 8 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/json-mode-function-calling-for-sql/verified-queries/most-expensive-purchase.yaml: -------------------------------------------------------------------------------- 1 | description: Employee with the most expensive purchase 2 | sql: | 3 | SELECT employees.name AS employee_name, 4 | MAX(amount) AS max_purchase_amount 5 | FROM purchases.csv AS purchases 6 | JOIN employees.csv AS employees ON purchases.employee_id = employees.employee_id 7 | GROUP BY employees.name 8 | ORDER BY max_purchase_amount DESC 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/json-mode-function-calling-for-sql/verified-queries/most-recent-purchases.yaml: -------------------------------------------------------------------------------- 1 | description: Five most recent purchases 2 | sql: | 3 | SELECT 4 | purchases.purchase_date, 5 | purchases.product_name, 6 | purchases.amount, 7 | employees.name 8 | FROM purchases.csv AS purchases 9 | JOIN employees.csv AS employees ON purchases.employee_id = employees.employee_id 10 | ORDER BY purchases.purchase_date DESC 11 | LIMIT 5; 12 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/json-mode-function-calling-for-sql/verified-queries/number-of-teslas.yaml: -------------------------------------------------------------------------------- 1 | description: Number of Teslas purchased 2 | sql: | 3 | SELECT COUNT(*) as number_of_teslas 4 | FROM purchases.csv AS p 5 | JOIN employees.csv AS e ON e.employee_id = p.employee_id 6 | WHERE p.product_name = 'Tesla' 7 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-api-cookbook/parallel-tool-use/requirements.txt: -------------------------------------------------------------------------------- 1 | groq 2 | python-dotenv 3 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/conversational-chatbot-langchain/README.md: -------------------------------------------------------------------------------- 1 | # Groq LangChain Conversational Chatbot 2 | 3 | A simple application that allows users to interact with a conversational chatbot powered by LangChain. The application uses the Groq API to generate responses and leverages LangChain's [ConversationBufferWindowMemory](https://python.langchain.com/v0.1/docs/modules/memory/types/buffer_window/) to maintain a history of the conversation to provide context for the chatbot's responses. 4 | 5 | ## Features 6 | 7 | - **Conversational Interface**: The application provides a conversational interface where users can ask questions or make statements, and the chatbot responds accordingly. 8 | 9 | - **Contextual Responses**: The application maintains a history of the conversation, which is used to provide context for the chatbot's responses. 10 | 11 | - **LangChain Integration**: The chatbot is powered by the LangChain API, which uses advanced natural language processing techniques to generate human-like responses. 12 | 13 | ## Usage 14 | 15 | 16 | 17 | You will need to store a valid Groq API Key as a secret to proceed with this example. You can generate one for free [here](https://console.groq.com/keys). 18 | 19 | 20 | 21 | You can [fork and run this application on Replit](https://replit.com/@GroqCloud/Chatbot-with-Conversational-Memory-on-LangChain) or run it on the command line with `python main.py` 22 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/conversational-chatbot-langchain/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/groq/groq-example-templates/conversational-chatbot-langchain/requirements.txt -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/crewai-agents/README.md: -------------------------------------------------------------------------------- 1 | # CrewAI Machine Learning Assistant 2 | 3 | ## Overview 4 | 5 | The [CrewAI](https://docs.crewai.com/) Machine Learning Assistant is a command line application designed to kickstart your machine learning projects. It leverages a team of AI agents to guide you through the initial steps of defining, assessing, and solving machine learning problems. 6 | 7 | ## Features 8 | 9 | - **Agents**: Utilizes specialized agents to perform tasks such as problem definition, data assessment, model recommendation, and code generation, enhancing the workflow and efficiency of machine learning projects. 10 | 11 | - **CrewAI Framework**: Integrates multiple agents into a cohesive framework, enabling seamless interaction and task execution to streamline the machine learning process. 12 | 13 | - **LangChain Integration**: Incorporates LangChain to facilitate natural language processing and enhance the interaction between the user and the machine learning assistant. 14 | 15 | ## Usage 16 | 17 | 18 | 19 | You will need to store a valid Groq API Key as a secret to proceed with this example. You can generate one for free [here](https://console.groq.com/keys). 20 | 21 | 22 | 23 | You can [fork and run this application on Replit](https://replit.com/@GroqCloud/CrewAI-Machine-Learning-Assistant) or run it on the command line with `python main.py`. You can upload a sample .csv to the same directory as `main.py` to give the application a head start on your ML problem. The application will output a Markdown file including python code for your ML use case to the same directory as main.py. 24 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/crewai-agents/requirements.txt: -------------------------------------------------------------------------------- 1 | crewai 2 | langchain_groq 3 | pandas -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/groq-quickstart-conversational-chatbot/README.md: -------------------------------------------------------------------------------- 1 | # Groq Quickstart Conversational Chatbot 2 | 3 | A simple application that allows users to interact with a conversational chatbot powered by Groq. This application is designed to get users up and running quickly with building a chatbot. 4 | 5 | ## Features 6 | 7 | **Conversational Interface**: Provides a simple interface where users can input text and receive responses from the chatbot. 8 | 9 | **Short Responses**: The chatbot replies with very short and concise answers, keeping interactions brief and to the point. 10 | 11 | **Groq Integration**: Utilizes the Groq API to generate responses, leveraging the power of the Llama3-70b-8192 model. 12 | 13 | ## Usage 14 | 15 | 16 | 17 | You will need to store a valid Groq API Key as a secret to proceed with this example. You can generate one for free [here](https://console.groq.com/keys). 18 | 19 | 20 | 21 | You can [fork and run this application on Replit](https://replit.com/@GroqCloud/Groq-Quickstart-Conversational-Chatbot) or run it on the command line with `python main.py`. 22 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/groq-quickstart-conversational-chatbot/main.py: -------------------------------------------------------------------------------- 1 | #set GROQ_API_KEY in the secrets 2 | 3 | import os 4 | from groq import Groq 5 | 6 | # Create the Groq client 7 | client = Groq( 8 | api_key=os.environ.get("GROQ_API_KEY") 9 | ) 10 | 11 | # Set the system prompt 12 | system_prompt = { 13 | "role": "system", 14 | "content": 15 | "You are a helpful assistant. You reply with very short answers." 16 | } 17 | 18 | # Initialize the chat history 19 | chat_history = [system_prompt] 20 | 21 | while True: 22 | # Get user input from the console 23 | user_input = input("You: ") 24 | 25 | # Append the user input to the chat history 26 | chat_history.append({"role": "user", "content": user_input}) 27 | 28 | response = client.chat.completions.create(model="llama3-70b-8192", 29 | messages=chat_history, 30 | max_tokens=100, 31 | temperature=1.2) 32 | # Append the response to the chat history 33 | chat_history.append({ 34 | "role": "assistant", 35 | "content": response.choices[0].message.content 36 | }) 37 | # Print the response 38 | print("Assistant:", response.choices[0].message.content) 39 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/groq-quickstart-conversational-chatbot/requirements.txt: -------------------------------------------------------------------------------- 1 | groq -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/groqing-the-stock-market-function-calling-llama3/requirements.txt: -------------------------------------------------------------------------------- 1 | streamlit 2 | pandas 3 | numpy 4 | groq 5 | langchain_community 6 | langchain_groq 7 | yfinance 8 | plotly 9 | langchain_core 10 | nbformat>=4.2.0 11 | ipython 12 | kaleido -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/llamachat-conversational-chatbot-with-llamaIndex/README.md: -------------------------------------------------------------------------------- 1 | # LlamaChat: Conversational Chatbot with LlamaIndex and Llama3 2 | 3 | A simple application that allows users to interact with a conversational chatbot powered by the LlamaIndex framework and Meta's Llama3 model. The application uses the Groq API to generate responses and supports different modes of interaction, including simple chat, streaming chat, and customizable chat with system prompts. 4 | 5 | ##Features 6 | 7 | **LlamaIndex**: The application uses LlamaIndex to manage and generate responses, leveraging the power of Groq's language model. 8 | 9 | **Simple Chat**: Generates responses based on user input using the Groq API with LlamaIndex. 10 | 11 | **Streaming Chat**: Provides real-time streaming responses for user input. 12 | 13 | **Customizable Chat**: Allows for chat customization by setting a system prompt to guide the chatbot's responses. 14 | 15 | ##Usage 16 | 17 | 18 | 19 | You will need to store a valid Groq API Key as a secret to proceed with this example. You can generate one for free [here](https://console.groq.com/keys). 20 | 21 | 22 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/llamachat-conversational-chatbot-with-llamaIndex/main.py: -------------------------------------------------------------------------------- 1 | from llama_index.llms.groq import Groq 2 | from llama_index.core.llms import ChatMessage 3 | 4 | llm = Groq(model="llama3-8b-8192") 5 | 6 | 7 | system_prompt = 'You are a friendly but highly sarcastic chatbot assistant' 8 | 9 | while True: 10 | # Get the user's question 11 | user_input = input("User: ") 12 | 13 | #user_input = 'write a few paragraphs explaining generative AI to a college freshman' 14 | 15 | ################################## 16 | # Simple Chat 17 | ################################## 18 | print('Simple Chat:\n\n') 19 | response = llm.complete(user_input) 20 | print(response) 21 | 22 | 23 | ################################## 24 | # Streaming Chat 25 | ################################## 26 | stream_response = llm.stream_complete( 27 | user_input 28 | ) 29 | print('\n\nStreaming Chat:\n') 30 | for t in stream_response: 31 | print(t.delta, end="") 32 | 33 | 34 | ################################## 35 | # Customizable Chat 36 | ################################## 37 | messages = [ 38 | ChatMessage(role="system", content=system_prompt), 39 | ChatMessage(role="user", content=user_input), 40 | ] 41 | print('\n\nChat with System Prompt:\n') 42 | response_with_system_prompt = llm.chat(messages) 43 | 44 | print(response_with_system_prompt) 45 | 46 | 47 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/llamachat-conversational-chatbot-with-llamaIndex/requirements.txt: -------------------------------------------------------------------------------- 1 | llama_index 2 | llama-index-llms-groq -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/presidential-speeches-rag-with-pinecone/requirements.txt: -------------------------------------------------------------------------------- 1 | pandas 2 | numpy 3 | groq 4 | langchain_community 5 | langchain_pinecone 6 | transformers 7 | scikit-learn 8 | sentence-transformers -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/text-to-sql-json-mode/data/employees.csv: -------------------------------------------------------------------------------- 1 | employee_id,name,email 2 | 1,Richard Hendricks,richard@piedpiper.com 3 | 2,Erlich Bachman,erlich@aviato.com 4 | 3,Dinesh Chugtai,dinesh@piedpiper.com 5 | 4,Bertram Gilfoyle,gilfoyle@piedpiper.com 6 | 5,Jared Dunn,jared@piedpiper.com 7 | 6,Monica Hall,monica@raviga.com 8 | 7,Gavin Belson,gavin@hooli.com -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/text-to-sql-json-mode/data/purchases.csv: -------------------------------------------------------------------------------- 1 | purchase_id,purchase_date,product_name,employee_id,amount 2 | 1,'2024-02-01',iPhone,1,750 3 | 2,'2024-02-02',Tesla,2,70000 4 | 3,'2024-02-03',Humane pin,3,500 5 | 4,'2024-02-04',iPhone,4,700 6 | 5,'2024-02-05',Tesla,5,75000 -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/text-to-sql-json-mode/requirements.txt: -------------------------------------------------------------------------------- 1 | duckdb 2 | groq 3 | sqlparse 4 | pandas 5 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/verified-sql-function-calling/data/employees.csv: -------------------------------------------------------------------------------- 1 | employee_id,name,email 2 | 1,Richard Hendricks,richard@piedpiper.com 3 | 2,Erlich Bachman,erlich@aviato.com 4 | 3,Dinesh Chugtai,dinesh@piedpiper.com 5 | 4,Bertram Gilfoyle,gilfoyle@piedpiper.com 6 | 5,Jared Dunn,jared@piedpiper.com 7 | 6,Monica Hall,monica@raviga.com 8 | 7,Gavin Belson,gavin@hooli.com -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/verified-sql-function-calling/data/purchases.csv: -------------------------------------------------------------------------------- 1 | purchase_id,purchase_date,product_name,employee_id,amount 2 | 1,'2024-02-01',iPhone,1,750 3 | 2,'2024-02-02',Tesla,2,70000 4 | 3,'2024-02-03',Humane pin,3,500 5 | 4,'2024-02-04',iPhone,4,700 6 | 5,'2024-02-05',Tesla,5,75000 -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/verified-sql-function-calling/requirements.txt: -------------------------------------------------------------------------------- 1 | groq 2 | sentence-transformers 3 | langchain_community 4 | scikit-learn 5 | numpy 6 | duckdb 7 | pyyaml 8 | sqlparse 9 | tabulate -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/verified-sql-function-calling/verified-queries/employees-without-purchases.yaml: -------------------------------------------------------------------------------- 1 | description: Employees without a purchase since Feb 1, 2024 2 | sql: | 3 | SELECT employees.name as employees_without_purchases 4 | FROM employees.csv AS employees 5 | LEFT JOIN purchases.csv AS purchases ON employees.employee_id = purchases.employee_id 6 | AND purchases.purchase_date > '2024-02-01' 7 | WHERE purchases.purchase_id IS NULL 8 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/verified-sql-function-calling/verified-queries/most-expensive-purchase.yaml: -------------------------------------------------------------------------------- 1 | description: Employee with the most expensive purchase 2 | sql: | 3 | SELECT employees.name AS employee_name, 4 | MAX(amount) AS max_purchase_amount 5 | FROM purchases.csv AS purchases 6 | JOIN employees.csv AS employees ON purchases.employee_id = employees.employee_id 7 | GROUP BY employees.name 8 | ORDER BY max_purchase_amount DESC 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/verified-sql-function-calling/verified-queries/most-recent-purchases.yaml: -------------------------------------------------------------------------------- 1 | description: Five most recent purchases 2 | sql: | 3 | SELECT purchases.product_name, 4 | purchases.amount, 5 | employees.name 6 | FROM purchases.csv AS purchases 7 | JOIN employees.csv AS employees ON purchases.employee_id = employees.employee_id 8 | ORDER BY purchases.purchase_date DESC 9 | LIMIT 5; 10 | -------------------------------------------------------------------------------- /3p-integrations/groq/groq-example-templates/verified-sql-function-calling/verified-queries/number-of-teslas.yaml: -------------------------------------------------------------------------------- 1 | description: Number of Teslas purchased 2 | sql: | 3 | SELECT COUNT(*) as number_of_teslas 4 | FROM purchases.csv AS p 5 | JOIN employees.csv AS e ON e.employee_id = p.employee_id 6 | WHERE p.product_name = 'Tesla' 7 | -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/README.md: -------------------------------------------------------------------------------- 1 | # Tune Llama 3 for text-to-SQL and improve accuracy from 30% to 95% 2 | 3 | This repo and notebook `meta_lamini.ipynb` demonstrate how to tune Llama 3 to generate valid SQL queries and improve accuracy from 30% to 95%. 4 | 5 | In this notebook we'll be using Lamini, and more specifically, Lamini Memory Tuning. 6 | 7 | Lamini is an integrated platform for LLM inference and tuning for the enterprise. Lamini Memory Tuning is a new tool you can use to embed facts into LLMs that improves factual accuracy and reduces hallucinations. Inspired by information retrieval, this method has set a new standard of accuracy for LLMs with less developer effort. 8 | 9 | Learn more about Lamini Memory Tuning: https://www.lamini.ai/blog/lamini-memory-tuning 10 | 11 | Please head over to https://app.lamini.ai/account to get your free api key. 12 | 13 | You can authenticate by writing the following to a file `~/.lamini/configure.yaml` 14 | 15 | ``` 16 | production: 17 | key: 18 | ``` 19 | 20 | This tuning tutorial uses the `nba_roster` sqlite database to tune a Llama 3 model. 21 | 22 | ## Additional resources 23 | 24 | ▫️ Fortune 500 case study: http://www.lamini.ai/blog/llm-text-to-sql
25 | ▫️ Technical paper: https://github.com/lamini-ai/Lamini-Memory-Tuning/blob/main/research-paper.pdf
26 | ▫️ Model weights: https://huggingface.co/engineering-lamini/lamini-1-random 27 | -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/assets/manual_filtering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/lamini/text2sql_memory_tuning/assets/manual_filtering.png -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/assets/website.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/lamini/text2sql_memory_tuning/assets/website.png -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/nba_roster.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/lamini/text2sql_memory_tuning/nba_roster.db -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/util/get_default_finetune_args.py: -------------------------------------------------------------------------------- 1 | def get_default_finetune_args(): 2 | return { 3 | "learning_rate": 0.0003, 4 | "max_steps": 60, 5 | "early_stopping": False, 6 | "load_best_model_at_end": False, 7 | "peft_args": {"r_value": 32}, 8 | } 9 | -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/util/get_rubric.py: -------------------------------------------------------------------------------- 1 | def get_rubric(): 2 | prompt = ( 3 | "Read this scoring rubric carefully and follow the instructions precisely:\n" 4 | ) 5 | prompt += ( 6 | "A score of 5 means that model's value is the same as the gold answer's id.\n" 7 | ) 8 | prompt += "A score of 4 means that the model's answer is the same or a paraphrase of the gold answer, but the value may not be an exact match.\n" 9 | prompt += "A score of 3 means that the model's answer is similar as the gold answer's description, but the value may be wrong. Both answers may indicate that revenue is increased but the gold says 12 percent and the model say 50 million USD.\n" 10 | prompt += "A score of 2 means that the model's answer is not similar to the gold answer, but the answer is plausible.\n" 11 | prompt += "A score of 1 means that the model's answer is not similar to the gold answer, and the answer doesn't make sense.\n" 12 | 13 | prompt += "Assign a 5 for a correct value even if other fields are missing.\n" 14 | 15 | return prompt 16 | -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/util/get_schema.py: -------------------------------------------------------------------------------- 1 | def get_schema(): 2 | return """\ 3 | 0|Team|TEXT eg. "Toronto Raptors" 4 | 1|NAME|TEXT eg. "Otto Porter Jr." 5 | 2|Jersey|TEXT eg. "0" and when null has a value "NA" 6 | 3|POS|TEXT eg. "PF" 7 | 4|AGE|INT eg. "22" in years 8 | 5|HT|TEXT eg. `6' 7"` or `6' 10"` 9 | 6|WT|TEXT eg. "232 lbs" 10 | 7|COLLEGE|TEXT eg. "Michigan" and when null has a value "--" 11 | 8|SALARY|TEXT eg. "$9,945,830" and when null has a value "--" 12 | """ 13 | -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/util/load_dataset.py: -------------------------------------------------------------------------------- 1 | import jsonlines 2 | 3 | from util.make_llama_3_prompt import make_llama_3_prompt 4 | 5 | 6 | def load_training_data(args, make_question): 7 | path = f"data/training_data/{args.training_file_name}" 8 | 9 | limit = 1000 10 | 11 | with jsonlines.open(path) as reader: 12 | for index, obj in enumerate(reversed(list(reader))): 13 | if index >= limit: 14 | break 15 | 16 | yield { 17 | "input": make_llama_3_prompt(**make_question(obj)), 18 | "output": obj["sql"] + "<|eot_id|>", 19 | } 20 | 21 | 22 | def get_dataset(args, make_question): 23 | dataset = list(load_training_data(args, make_question)) 24 | return dataset 25 | -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/util/make_llama_3_prompt.py: -------------------------------------------------------------------------------- 1 | def make_llama_3_prompt(user, system=""): 2 | system_prompt = "" 3 | if system != "": 4 | system_prompt = ( 5 | f"<|start_header_id|>system<|end_header_id|>\n\n{system}<|eot_id|>" 6 | ) 7 | return f"<|begin_of_text|>{system_prompt}<|start_header_id|>user<|end_header_id|>\n\n{user}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n" 8 | -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/util/parse_arguments.py: -------------------------------------------------------------------------------- 1 | from argparse import ArgumentParser 2 | 3 | 4 | def parse_arguments(): 5 | parser = ArgumentParser() 6 | 7 | # The max number of examples to evaluate 8 | parser.add_argument( 9 | "--max-examples", 10 | type=int, 11 | default=100, 12 | help="The max number of examples to evaluate", 13 | required=False, 14 | ) 15 | 16 | parser.add_argument( 17 | "--sql-model-name", 18 | type=str, 19 | default="meta-llama/Meta-Llama-3.1-8B-Instruct", 20 | help="The model to use for text2sql", 21 | required=False, 22 | ) 23 | 24 | parser.add_argument( 25 | "--gold-file-name", 26 | type=str, 27 | default="gold-test-set.jsonl", 28 | help="The gold dataset to use as seed", 29 | required=False, 30 | ) 31 | 32 | parser.add_argument( 33 | "--training-file-name", 34 | type=str, 35 | default="generated_queries.jsonl", 36 | help="The training dataset", 37 | required=False, 38 | ) 39 | 40 | return parser.parse_args() 41 | -------------------------------------------------------------------------------- /3p-integrations/lamini/text2sql_memory_tuning/util/setup_logging.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | 4 | def setup_logging(): 5 | # Remove all handlers associated with the root logger object. 6 | for handler in logging.root.handlers[:]: 7 | logging.root.removeHandler(handler) 8 | 9 | logging.basicConfig( 10 | level=logging.WARNING, 11 | format="%(asctime)s [%(levelname)s] %(message)s", 12 | handlers=[logging.StreamHandler()], 13 | ) 14 | -------------------------------------------------------------------------------- /3p-integrations/llamaindex/dlai_agentic_rag/README.md: -------------------------------------------------------------------------------- 1 | # Building Agentic RAG with Llamaindex 2 | 3 | The folder here contains the Llama 3 ported notebooks of the DLAI short course [Building Agentic RAG with Llamaindex](https://www.deeplearning.ai/short-courses/building-agentic-rag-with-llamaindex/). 4 | 5 | 1. [Building Agentic RAG with Llamaindex L1 Router Engine](../../../end-to-end-use-cases/agents/DeepLearningai_Course_Notebooks/AI_Agents_in_LangGraph_L1_Build_an_Agent_from_Scratch.ipynb) shows how to implement a simple agentic RAG, a router that will pick up one of several query tools (question answering or summarization) to execute a query on a single document. Note this notebook is located in the `quickstart` folder. 6 | 7 | 2. [Building Agentic RAG with Llamaindex L2 Tool Calling](Building_Agentic_RAG_with_Llamaindex_L2_Tool_Calling.ipynb) shows how to use Llama 3 to not only pick a function to execute, but also infer an argument to pass through the function. 8 | 9 | 3. [Building Agentic RAG with Llamaindex L3 Building an Agent Reasoning Loop](Building_Agentic_RAG_with_Llamaindex_L3_Building_an_Agent_Reasoning_Loop.ipynb) shows how to define a complete agent reasoning loop to reason over tools and multiple steps on a complex question the user asks about a single document while maintaining memory. 10 | 11 | 3. [Building Agentic RAG with Llamaindex L4 Building a Multi-Document Agent](Building_Agentic_RAG_with_Llamaindex_L4_Building_a_Multi-Document_Agent.ipynb) shows how to use an agent to handle multiple documents and increasing degrees of complexity. 12 | -------------------------------------------------------------------------------- /3p-integrations/modal/many-llamas-human-eval/run_e2e.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | command -v modal >/dev/null 2>&1 || { echo >&2 "modal command not found. Install modal first! Aborting."; exit 1; } 6 | 7 | echo 'downloading LLaMA 3.2 3B Instruct model' 8 | echo 'make sure to create a Secret called huggingface on Modal and accept the LLaMA 3.2 license' 9 | modal run download.py 10 | 11 | echo 'deploying vLLM inference server' 12 | modal deploy inference.py 13 | 14 | echo 'running HumanEval generation' 15 | modal run generate.py --data-dir test --no-dry-run --n 1000 --subsample 100 16 | 17 | echo 'running HumanEval evaluation' 18 | modal run eval.py 19 | 20 | echo 'generating graphs for pass@k and fail@k' 21 | modal run plot.py -------------------------------------------------------------------------------- /3p-integrations/tgi/merge_lora_weights.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement. 3 | 4 | import fire 5 | import torch 6 | from peft import PeftModel 7 | from transformers import LlamaForCausalLM, LlamaTokenizer 8 | 9 | 10 | def main(base_model: str, 11 | peft_model: str, 12 | output_dir: str): 13 | 14 | model = LlamaForCausalLM.from_pretrained( 15 | base_model, 16 | load_in_8bit=False, 17 | torch_dtype=torch.float16, 18 | device_map="auto", 19 | offload_folder="tmp", 20 | ) 21 | 22 | tokenizer = LlamaTokenizer.from_pretrained( 23 | base_model 24 | ) 25 | 26 | model = PeftModel.from_pretrained( 27 | model, 28 | peft_model, 29 | torch_dtype=torch.float16, 30 | device_map="auto", 31 | offload_folder="tmp", 32 | ) 33 | 34 | model = model.merge_and_unload() 35 | model.save_pretrained(output_dir) 36 | tokenizer.save_pretrained(output_dir) 37 | 38 | 39 | if __name__ == "__main__": 40 | fire.Fire(main) -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/BERTScore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/BERTScore.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/CoQA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/CoQA.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/ColPaliMaxSim-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/ColPaliMaxSim-1.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/Nvidia_collage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/Nvidia_collage.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/UMAP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/UMAP.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/cRAG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/cRAG.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/cRAG_indexing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/cRAG_indexing.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/cRAG_querytime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/cRAG_querytime.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/cluster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/cluster.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/colpali_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/colpali_arch.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/conversation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/conversation.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/deploy_CFT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/deploy_CFT.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/ft_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/ft_model.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/mmrag_only.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/mmrag_only.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/page_25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/page_25.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/repetition_task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/repetition_task.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/reranking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/reranking.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/semantic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/semantic_search.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/simple_RAG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/simple_RAG.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/structured_text_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/structured_text_image.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/summarization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/summarization.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/summary_task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/summary_task.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/text_RAG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/text_RAG.png -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/together-color.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/together-color.jpg -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/together.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/together.gif -------------------------------------------------------------------------------- /3p-integrations/togetherai/images/wandb_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/3p-integrations/togetherai/images/wandb_model.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Meta Platforms, Inc. and affiliates 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /UPDATES.md: -------------------------------------------------------------------------------- 1 | DIFFLOG: 2 | 3 | Nested Folders rename: 4 | - /recipes/3p_integrations -> /3p-integrations 5 | - /recipes/quickstart -> /getting-started 6 | - /recipes/responsible_ai -> /end-to-end-use-cases/responsible_ai 7 | - /recipes/use_cases -> /end-to-end-use-cases 8 | - /quickstart/agents -> /end-to-end-use-cases/agents 9 | - /quickstart/NotebookLlama -> /end-to-end-use-cases/NotebookLlama 10 | - /quickstart/responsible_ai -> /end-to-end-use-cases/responsible_ai 11 | - /recipes/use_cases/end-toend/RAFT-Chatbot -> /end-to-end-use-cases/RAFT-Chatbot 12 | - /docs -> /src/docs/ 13 | - /dev_requirements.txt -> /src/dev_requirements.txt 14 | - /requirements.txt -> /src/requirements.txt 15 | - /tools -> /end-to-end-use-cases/benchmarks/ 16 | - /recipes/experimental/long_context -> /end-to-end-use-cases/long_context 17 | 18 | 19 | Removed folders: 20 | - /flagged (Empty folder) 21 | - /recipes/quickstart/Running_Llama3_Anywhere (Redundant code) 22 | - /recipes/quickstart/inference/codellama (deprecated model) 23 | - /recipes/quickstart/getting-to-know-llama-3.ipynb 24 | 25 | -------------------------------------------------------------------------------- /dev_requirements.txt: -------------------------------------------------------------------------------- 1 | vllm 2 | pytest-mock 3 | auditnlg -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle files 2 | .gradle/ 3 | build/ 4 | 5 | # Local configuration file (sdk path, etc) 6 | local.properties 7 | 8 | # Log/OS Files 9 | *.log 10 | 11 | # Android Studio generated files and folders 12 | captures/ 13 | .externalNativeBuild/ 14 | .cxx/ 15 | *.apk 16 | output.json 17 | 18 | # IntelliJ 19 | *.iml 20 | .idea/ 21 | misc.xml 22 | deploymentTargetDropDown.xml 23 | render.experimental.xml 24 | 25 | # Keystore files 26 | *.jks 27 | *.keystore 28 | 29 | # Google Services (e.g. APIs or Firebase) 30 | google-services.json 31 | 32 | # Android Profiling 33 | *.hprof 34 | 35 | .DS_Store 36 | 37 | *.jar 38 | *.aar 39 | *.so 40 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/README.md: -------------------------------------------------------------------------------- 1 | # Android Document Summarizer App 2 | 3 | 4 | 5 | 6 | This is a sample Android app to demonstrate Llama 4 multimodal and multilingual capabilities. This app allows user to take a picture/screenshot of a document, and then summarize and translate it into any of the supported languages 7 | 8 | ## Quick Start 9 | 10 | 1. Open the DocumentSummarizer folder in Android Studio 11 | 2. Update the `API_KEY` in `AppUtils.java` 12 | 3. Build the Android Project 13 | 4. Inside the app, tap on settings icon on top right 14 | 5. Configure the Remote URL endpoint (any supported providers that serve Llama 4 models. For example: https://api.together.xyz) 15 | 6. Select the desired model from the drop down list. If you need to add more models, modify `ModelUtils.java` 16 | 7. Go back to the Main chat window 17 | 8. Press the '+' button on the bottom left and select an image document (or take a picture of one!) 18 | 9. Select the 'globe' button on the bottom left and select your languages 19 | 10. Enter a prompt like "summarize this" and press Enter! 20 | 21 | > **_NOTE:_** This is an example project to demonstrate E2E flow. You should NOT use/store API key directly on client. Exposing your API key in client-side environments allows malicious users to take that key and make requests on your behalf. Requests should always be routed through your own backend server where you can keep your API key secure. 22 | 23 | 24 | ## Reporting Issues 25 | If you encountered any bugs or issues following this tutorial please file a bug/issue here on [Github](https://github.com/meta-llama/llama-cookbook/issues)). 26 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/AppLog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | package com.example.llamaandroiddemo; 10 | 11 | import java.text.SimpleDateFormat; 12 | import java.util.Date; 13 | import java.util.Locale; 14 | 15 | public class AppLog { 16 | private final Long timestamp; 17 | private final String message; 18 | 19 | public AppLog(String message) { 20 | this.timestamp = getCurrentTimeStamp(); 21 | this.message = message; 22 | } 23 | 24 | public Long getTimestamp() { 25 | return timestamp; 26 | } 27 | 28 | public String getMessage() { 29 | return message; 30 | } 31 | 32 | public String getFormattedLog() { 33 | return "[" + getFormattedTimeStamp() + "] " + message; 34 | } 35 | 36 | private Long getCurrentTimeStamp() { 37 | return System.currentTimeMillis(); 38 | } 39 | 40 | private String getFormattedTimeStamp() { 41 | return formatDate(timestamp); 42 | } 43 | 44 | private String formatDate(long milliseconds) { 45 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); 46 | Date date = new Date(milliseconds); 47 | return formatter.format(date); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/AppLogging.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | package com.example.llamaandroiddemo; 10 | 11 | import android.app.Application; 12 | import android.util.Log; 13 | import java.util.ArrayList; 14 | 15 | public class AppLogging extends Application { 16 | private static AppLogging singleton; 17 | 18 | private ArrayList logs; 19 | private DemoSharedPreferences mDemoSharedPreferences; 20 | 21 | @Override 22 | public void onCreate() { 23 | super.onCreate(); 24 | singleton = this; 25 | mDemoSharedPreferences = new DemoSharedPreferences(this.getApplicationContext()); 26 | logs = mDemoSharedPreferences.getSavedLogs(); 27 | if (logs == null) { // We don't have existing sharedPreference stored 28 | logs = new ArrayList<>(); 29 | } 30 | } 31 | 32 | public static AppLogging getInstance() { 33 | return singleton; 34 | } 35 | 36 | public void log(String message) { 37 | AppLog appLog = new AppLog(message); 38 | logs.add(appLog); 39 | Log.d("AppLogging", appLog.getMessage()); 40 | } 41 | 42 | public ArrayList getLogs() { 43 | return logs; 44 | } 45 | 46 | public void clearLogs() { 47 | logs.clear(); 48 | mDemoSharedPreferences.removeExistingLogs(); 49 | } 50 | 51 | public void saveLogs() { 52 | mDemoSharedPreferences.saveLogs(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/AppUtils.java: -------------------------------------------------------------------------------- 1 | package com.example.llamaandroiddemo; 2 | 3 | public class AppUtils { 4 | // Generation Mode 5 | public static final int CONVERSATION_HISTORY_MESSAGE_LOOKBACK = 1; 6 | 7 | // Note: This is an example project to demonstrate E2E flow. 8 | // You should NOT use/store API key directly on client 9 | // Exposing your API key in client-side environments allows malicious users to take 10 | // that key and make requests on your behalf. Requests should always be routed through 11 | // your own backend server where you can keep your API key secure. 12 | public static final String API_KEY = ""; 13 | } 14 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/HomescreenActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.llamaandroiddemo 2 | 3 | import android.content.Intent 4 | import androidx.appcompat.app.AppCompatActivity 5 | import android.os.Bundle 6 | import android.widget.Button 7 | 8 | class HomescreenActivity : AppCompatActivity() { 9 | 10 | private lateinit var startChatButton: Button 11 | 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | setContentView(R.layout.activity_homescreen) 15 | 16 | // Initialize UI components 17 | startChatButton = findViewById(R.id.btn_start_chat) 18 | 19 | // Set up start chat button click listener 20 | startChatButton.setOnClickListener { 21 | val intent = Intent(this, MainActivity::class.java) 22 | startActivity(intent) 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/LogsAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | package com.example.llamaandroiddemo; 10 | 11 | import android.view.LayoutInflater; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.widget.ArrayAdapter; 15 | import android.widget.TextView; 16 | import androidx.annotation.NonNull; 17 | import java.util.Objects; 18 | 19 | public class LogsAdapter extends ArrayAdapter { 20 | public LogsAdapter(android.content.Context context, int resource) { 21 | super(context, resource); 22 | } 23 | 24 | static class ViewHolder { 25 | private TextView logTextView; 26 | } 27 | 28 | @NonNull 29 | @Override 30 | public View getView(int position, View convertView, @NonNull ViewGroup parent) { 31 | ViewHolder mViewHolder = null; 32 | 33 | String logMessage = Objects.requireNonNull(getItem(position)).getFormattedLog(); 34 | 35 | if (convertView == null || convertView.getTag() == null) { 36 | mViewHolder = new ViewHolder(); 37 | convertView = LayoutInflater.from(getContext()).inflate(R.layout.logs_message, parent, false); 38 | mViewHolder.logTextView = convertView.requireViewById(R.id.logsTextView); 39 | } else { 40 | mViewHolder = (ViewHolder) convertView.getTag(); 41 | } 42 | mViewHolder.logTextView.setText(logMessage); 43 | return convertView; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/MessageType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | package com.example.llamaandroiddemo; 10 | 11 | public enum MessageType { 12 | TEXT, 13 | IMAGE, 14 | SYSTEM 15 | } 16 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/ModelType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | package com.example.llamaandroiddemo; 10 | 11 | public enum ModelType { 12 | LLAMA_3, 13 | LLAMA_3_1, 14 | LLAMA_3_2, 15 | LLAMA_GUARD_3, 16 | } 17 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/ModelUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | package com.example.llamaandroiddemo; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class ModelUtils { 15 | public static List getSupportedRemoteModels() { 16 | // UPDATE THIS TO THE RELEVANT MODELS YOU WANT TO USE 17 | // NOTE THAT SOME PROVIDERS MIGHT HAVE DIFFERENT MODEL NAMING FORMAT 18 | return Arrays.asList( 19 | "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", 20 | "meta-llama/Llama-4-Scout-17B-16E-Instruct" 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/java/com/example/llamaandroiddemo/PromptFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | package com.example.llamaandroiddemo; 10 | 11 | public class PromptFormat { 12 | public static final String DEFAULT_SYSTEM_PROMPT = ""; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/banner_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_add_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_add_photo_alternate_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_article_24.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_close_24.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_delete_forever_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_language_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_restart_alt_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_send_24.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/baseline_stop_24.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/chat_background.xml: -------------------------------------------------------------------------------- 1 | 7 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/custom_button_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/expand_circle_down.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | 31 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/input_text_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/outline_add_box_48.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/outline_camera_alt_48.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/outline_image_48.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/prompt_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/received_message.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/sent_message.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/summarizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/summarizer.png -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/drawable/three_dots.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/layout/activity_benchmarking.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/layout/logs_message.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/layout/system_message.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 22 | 23 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-llama/llama-cookbook/ddd7429c6191feec6a5b1c35d59b4d843c05b761/end-to-end-use-cases/ArticleSummarizer/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #4294F0 4 | #3700B3 5 | #03DAC5 6 | #007CBA 7 | #A2A4B6 8 | #16293D 9 | #16293D 10 | 11 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Llama Demo 3 | DemoPrefFileKey 4 | SavedMessagesJsonKey 5 | SettingsJsonKey 6 | LogsJsonKey 7 | Start Chat 8 | 9 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /end-to-end-use-cases/ArticleSummarizer/app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |