-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4830c32
commit 9a834c8
Showing
204 changed files
with
19,298 additions
and
18,364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: fefabd31c006fccbf2184c02cc42bcc2 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: d8cefa79ab12cb8ecedbc3e87b5d26f0 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
# Generative AI Security Adventures | ||
|
||
[![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://cyb3rward0g.github.io/GPT-Security-Adventures/README.html) | ||
[![Open Source Love svg1](https://badges.frapsoft.com/os/v3/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Cyb3rWard0g/GPT-Security-Adventures/blob/main/LICENSE) | ||
|
||
An open-source initiative to share notes, presentations, and a diverse collection of experiments presented in Jupyter Notebooks, all aimed at helping you grasp the essential concepts behind large language models and exploring the intriguing intersection of security and natural language processing. | ||
|
||
## https://otrf.github.io/GenAI-Security-Adventures/README.html | ||
|
||
## Contributing | ||
|
||
We encourage everyone interested in exploring the connection between security and natural language processing using large language models, such as those from the GPT family, to contribute to our project. If you have an experiment that you would like to share, please don't hesitate to submit a pull request! Consider this repository as a platform to showcase your proof of concept before creating a more advanced repository to put it into action. Your contributions are highly valued and welcomed! | ||
|
||
## Presentations | ||
|
||
* X33fcon 2023 - Empowering Security Teams with Generative AI: Fundamentals and Applications of GPT models ([slides](https://1drv.ms/b/s!Al3n8YlNIUPUhk0s7GVXOnA53ggE?e=N7jhVP)) | ||
# Generative AI Security Adventures | ||
|
||
[![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://cyb3rward0g.github.io/GPT-Security-Adventures/README.html) | ||
[![Open Source Love svg1](https://badges.frapsoft.com/os/v3/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Cyb3rWard0g/GPT-Security-Adventures/blob/main/LICENSE) | ||
|
||
An open-source initiative to share notes, presentations, and a diverse collection of experiments presented in Jupyter Notebooks, all aimed at helping you grasp the essential concepts behind large language models and exploring the intriguing intersection of security and natural language processing. | ||
|
||
## https://otrf.github.io/GenAI-Security-Adventures/README.html | ||
|
||
## Contributing | ||
|
||
We encourage everyone interested in exploring the connection between security and natural language processing using large language models, such as those from the GPT family, to contribute to our project. If you have an experiment that you would like to share, please don't hesitate to submit a pull request! Consider this repository as a platform to showcase your proof of concept before creating a more advanced repository to put it into action. Your contributions are highly valued and welcomed! | ||
|
||
## Presentations | ||
|
||
* X33fcon 2023 - Empowering Security Teams with Generative AI: Fundamentals and Applications of GPT models ([slides](https://1drv.ms/b/s!Al3n8YlNIUPUhk0s7GVXOnA53ggE?e=N7jhVP)) | ||
* NDC Security 2023 - Empowering Security Teams with Generative AI: Fundamentals and Applications of GPT models ([slides](https://www.canva.com/design/DAF5d45kTik/t0te4HGMeqL0ja9-ZOzh0g/view?utm_content=DAF5d45kTik&utm_campaign=designshare&utm_medium=link&utm_source=editor)) |
This file was deleted.
Oops, something went wrong.
220 changes: 220 additions & 0 deletions
220
_sources/experiments/Agents/CoT/Local-CoT-Ollama-LiteLLM-Zephyr.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# CoT Reasoning: Chatting with Zephyr 7b Beta\n", | ||
"---\n", | ||
"* Collaborators:\n", | ||
" * Roberto Rodriguez (@Cyb3rWard0g)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Import Modules" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import openai" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Initialize OpenAI Client" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import openai\n", | ||
"client = openai.OpenAI(\n", | ||
" api_key=\"anything\",\n", | ||
" base_url=\"http://127.0.0.1:8000\"\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Define Completion Function" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def get_completion(prompt, model=\"zephyr-7B-beta\"):\n", | ||
" messages = [{\"role\":\"user\", \"content\":prompt}]\n", | ||
" response = client.chat.completions.create(\n", | ||
" model=model,\n", | ||
" messages=messages\n", | ||
" )\n", | ||
" return response.choices[0].message.content" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Direct Reasoning" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Define Prompt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"prompt = \"\"\"\n", | ||
"How would I get to Machu Picchu (Peru) from Virginia (USA)?\n", | ||
"\"\"\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Run Prompt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Unfortunately, there is no direct flight or land route connecting Virginia in the United States to Machu Picchu in Peru. You'll need to fly from Virginia to a major international airport, such as JFK in New York City, and then connect to a flight to Cusco, Peru (CUZ). From Cusco, you can take a train or bus to the nearby town of Aguas Calientes, where most people stay overnight before visiting Machu Picchu.\n", | ||
"\n", | ||
"Here's an outline of what your travel itinerary might look like:\n", | ||
"\n", | ||
"1. Fly from Virginia (IAD) to JFK (New York City)\n", | ||
"2. Stay overnight in New York City or connect to a flight to Cusco (CUZ)\n", | ||
"3. Arrive in Cusco and spend a few days acclimatizing to the altitude and exploring the city's many attractions\n", | ||
"4. Take a train or bus to Aguas Calientes, where you'll stay overnight before visiting Machu Picchu the next morning\n", | ||
"5. Spend a full day exploring Machu Picchu and hiking nearby trails (such as Huayna Picchu)\n", | ||
"6. Return to Cusco and continue your travels in Peru or fly back to Virginia (IAD) from there\n", | ||
"\n", | ||
"The total travel time will depend on various factors, including the number of connections needed between Virginia and Cusco, layovers, flight schedules, and any delays that may occur.\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"response = get_completion(prompt)\n", | ||
"print(response)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Zero-Shot CoT" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Define Prompt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"prompt = \"\"\"\n", | ||
"How would I get to Machu Picchu (Peru) from Virginia (USA)?. Think step by step.\n", | ||
"\"\"\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Run Prompt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"1. Research flights: First, check for flights from major airports near Virginia (such as Dulles International Airport or Washington Dulles International Airport) to Lima, Peru's capital city. Major airlines that operate flights between these two destinations include American Airlines, Delta Air Lines, and United Airlines.\n", | ||
"\n", | ||
"2. Book your flight: Once you've found a suitable flight, book it online through the airline's website or a travel booking site like Expedia or Kayak. Be sure to consider the cost of the flight, layovers, and connection times.\n", | ||
"\n", | ||
"3. Apply for a Peruvian visa (if required): US citizens do not require a visa for stays in Peru of up to 90 days, but it's always best to double-check the requirements before departing.\n", | ||
"\n", | ||
"4. Arrange transportation from Lima to Cusco: After arriving in Lima, you can take a connecting flight or a bus to Cusco (the closest major city to Machu Picchu). Popular bus companies include Cruz del Sur and Oltursa. Alternatively, you may choose to take the train directly to Aguas Calientes, the nearest town to Machu Picchu.\n", | ||
"\n", | ||
"5. Book accommodations: Cusco is a popular tourist destination, so it's best to book your accommodation ahead of time. Hostels, guesthouses, and hotels are available at various price points.\n", | ||
"\n", | ||
"6. Plan your visit to Machu Picchu: The entrance to Machu Picchu is located in Aguas Calientes. You can either hike the Inca Trail or take a bus up to the site. It's recommended to book your tickets online in advance, as they sell out quickly during peak tourist season.\n", | ||
"\n", | ||
"7. Prepare for the trip: Pack appropriate clothing and gear for the altitude and weather conditions. Consider hiring a guide or taking a tour to make the most of your visit to Machu Picchu. Also, remember to bring plenty of water, sunscreen, and insect repellent.\n", | ||
"\n", | ||
"8. Departure from Cusco: After leaving Machu Picchu, you'll need to return to Cusco before departing Peru. From there, you can take a connecting flight back to Lima or the US. \n", | ||
"\n", | ||
"This is just a basic overview, but hopefully, it provides a good starting point for planning your trip. Always consult official sources like Peru's government tourism website and the U.S Embassy in Peru for more detailed information regarding visa requirements and safety tips.\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"response = get_completion(prompt)\n", | ||
"print(response)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.11.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
_sources/experiments/Basics/Local-Ollama-LiteLLM-Zephyr.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Local Ollama and LiteLLM: Basic Chat Completion API\n", | ||
"---\n", | ||
"* Collaborators:\n", | ||
" * Roberto Rodriguez (@Cyb3rWard0g)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Import Modules" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from openai import OpenAI" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Initialize OpenAI Client" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"client = OpenAI(\n", | ||
" api_key=\"anything\",\n", | ||
" base_url=\"http://127.0.0.1:8000\"\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Define Completion Function" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def get_completion(prompt, model=\"ollama/zephyr:7b-beta\"):\n", | ||
" messages = [{\"role\":\"user\", \"content\":prompt}]\n", | ||
" response = client.chat.completions.create(\n", | ||
" model=model,\n", | ||
" messages=messages\n", | ||
" )\n", | ||
" return response.choices[0].message.content" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Run Prompt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"\"Why did the tomato turn red?\\nBecause it saw the salad dressing and wanted to fit in!\\n\\nWhy don't scientists trust atoms?\\nBecause they make up everything!\\n\\nWhy do seagulls fly over the sea?\\nBecause if they flew over the land, they would be bagels!\\n\\nWhy did the chicken cross the playground?\\nTo get to the other slide!\\n\\nWhy do scarecrows work on farms all summer long but never get a tan?\\nBecause they are made of straw!\\n\\nHow does a penguin build its house?\\nIgloos it together!\\n\\nWhat do you call an alligator in a vest?\\nAn investigator!\\n\\nWhy did the coffee file a police report?\\nIt got mugged!\\n\\nWhy don't ostriches like the circus?\\nBecause of all the tightrope walkers!\\n\\nWhat does a computer wear to bed?\\nSoftware!\\n\\nWhy do elephants paint their toenails red?\\nBecause blue looks better!\\n\\nWhy did the bike fall in love with the car?\\nBecause it was two-seater!\\n\\nWhy don't scientists trust atoms?\\nBecause they make up everything!\\n\\nWhy are ghosts bad liars?\\nBecause they are easy to see through!\"" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"get_completion(\"Tell me a Joke!\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.12.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.