Skip to content

submission-architectsoffuture #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,503 changes: 1,503 additions & 0 deletions architects_of_future/FineTuned/RAG.ipynb

Large diffs are not rendered by default.

2,222 changes: 2,222 additions & 0 deletions architects_of_future/FineTuned/Zephyrfinetune.ipynb

Large diffs are not rendered by default.

1,252 changes: 1,252 additions & 0 deletions architects_of_future/FineTuned/sumarization_t5model.ipynb

Large diffs are not rendered by default.

1,210 changes: 1,210 additions & 0 deletions architects_of_future/IDC notebook/LLM_finetuning.ipynb

Large diffs are not rendered by default.

812 changes: 812 additions & 0 deletions architects_of_future/IDC notebook/simple_llm_inference.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "84068c6d-79a1-4fee-a9c0-215b1141ea5a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: transformers in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (4.34.1)\n",
"Requirement already satisfied: filelock in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from transformers) (3.13.1)\n",
"Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from transformers) (0.17.3)\n",
"Requirement already satisfied: numpy>=1.17 in /opt/intel/oneapi/intelpython/python3.9/lib/python3.9/site-packages (from transformers) (1.24.3)\n",
"Requirement already satisfied: packaging>=20.0 in /opt/intel/oneapi/intelpython/python3.9/lib/python3.9/site-packages (from transformers) (23.1)\n",
"Requirement already satisfied: pyyaml>=5.1 in /opt/intel/oneapi/intelpython/python3.9/lib/python3.9/site-packages (from transformers) (6.0)\n",
"Requirement already satisfied: regex!=2019.12.17 in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from transformers) (2023.10.3)\n",
"Requirement already satisfied: requests in /opt/intel/oneapi/intelpython/python3.9/lib/python3.9/site-packages (from transformers) (2.31.0)\n",
"Requirement already satisfied: tokenizers<0.15,>=0.14 in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from transformers) (0.14.1)\n",
"Requirement already satisfied: safetensors>=0.3.1 in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from transformers) (0.4.1)\n",
"Requirement already satisfied: tqdm>=4.27 in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from transformers) (4.66.1)\n",
"Requirement already satisfied: fsspec in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->transformers) (2023.9.2)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->transformers) (4.8.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /opt/intel/oneapi/intelpython/python3.9/lib/python3.9/site-packages (from requests->transformers) (3.1.0)\n",
"Requirement already satisfied: idna<4,>=2.5 in /opt/intel/oneapi/intelpython/python3.9/lib/python3.9/site-packages (from requests->transformers) (3.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages (from requests->transformers) (1.26.15)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /opt/intel/oneapi/intelpython/python3.9/lib/python3.9/site-packages (from requests->transformers) (2023.7.22)\n"
]
}
],
"source": [
"!pip install transformers\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "73ba3f3e-1c0a-41a7-8b50-2a7b2a0ee1ff",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d162abb19fb34a39a99526088a34714d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Loading checkpoint shards: 0%| | 0/8 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"<s> what is article 144 of indian "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/u8c206d93f653f456d22b878722b9483/.local/lib/python3.9/site-packages/transformers/generation/utils.py:1421: UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use and modify the model generation configuration (see https://huggingface.co/docs/transformers/generation_strategies#default-text-generation-configuration )\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"law?\n",
"\n",
"Article 144 of the Indian Constitution is a provision that empowers the State to issue prohibitory orders in the interest of public order. It is also known as the \"Maintenance of Public Order\" provision. The State can impose restrictions on the right to freedom of speech, assembly, and movement under Article 19 of the Constitution in order to maintain public order. The orders issued under Article 144 can be preventive in nature, and are intended to prevent the occurrence of any untoward incidents or disturbances. The orders can be issued by the State Government or the District Magistrate, and can be in force for a specified period. The orders can also be extended to other areas if the situation so demands. The use of Article 144 is subject to certain conditions, such as the need for the orders to be reasonable, proportionate, and necessary in the circumstances. The orders must also be communicated to the public, and the affected persons must be given an opportunity to represent their views. The orders can be challenged in a court of law if they are deemed to be unreasonable or excessive.</s>\n",
"Inference time: 124.3553466796875 seconds \n"
]
}
],
"source": [
"from transformers import AutoTokenizer, TextStreamer\n",
"from transformers import AutoModelForCausalLM\n",
"import time\n",
"model_name = \"HuggingFaceH4/zephyr-7b-beta\" # Hugging Face model_id or local model\n",
"prompt = \"what is article 144 of indian law\"\n",
"\n",
"tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)\n",
"inputs = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"streamer = TextStreamer(tokenizer)\n",
"start=time.time()\n",
"model = AutoModelForCausalLM.from_pretrained(model_name, load_in_8bit=False)\n",
"outputs = model.generate(inputs, streamer=streamer, max_new_tokens=300)\n",
"end=time.time()\n",
"inference_time=end-start\n",
"print(f\"Inference time: {inference_time} seconds \")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f0e6f9e9-c098-4537-8961-df649fa904f6",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "tensorflow-gpu",
"language": "python",
"name": "tensorflow-gpu"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading