This file contains hidden or 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
"""CORS or "Cross-Origin Resource Sharing" refers to the situations when a frontend running in a browser has JavaScript code that communicates with a backend, and the backend is in a different "origin" than the frontend. | |
Origin | |
An origin is the combination of protocol (http, https), domain (myapp.com, localhost, localhost.tiangolo.com), and port (80, 443, 8080). | |
So, all these are different origins: | |
http://localhost |
This file contains hidden or 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
// Create an application | |
npx create-expo-app rate-repository-app --template expo-template-blank@sdk-50 | |
// Note, that the @sdk-50 sets the project's Expo SDK version to 50, which supports React Native version 0.73. | |
// Install dependencies | |
npx expo install react-native-web@~0.19.6 [email protected] @expo/metro-runtime@~3.1.1 | |
// Start the emulator |
This file contains hidden or 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
# Load docs | |
from langchain.document_loaders import WebBaseLoader | |
loader = WebBaseLoader("https://lilianweng.github.io/posts/2023-06-23-agent/") | |
data = loader.load() | |
# Split | |
from langchain.text_splitter import RecursiveCharacterTextSplitter | |
text_splitter = RecursiveCharacterTextSplitter(chunk_size = 500, chunk_overlap = 0) | |
all_splits = text_splitter.split_documents(data) |
This file contains hidden or 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
Show all tmux sessions | |
$ tmux ls | |
Start a new session | |
$ tmux | |
Start a new named session | |
$ tmux new -s <myname> | |
This file contains hidden or 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
https://colab.research.google.com/drive/1yFphU6PW9Uo6lmDly_ud9a6c4RCYlwdX#scrollTo=Mq2PKplWfbFv | |
https://mccormickml.com/2019/05/14/BERT-word-embeddings-tutorial/#31-running-bert-on-our-text | |
# -*- coding: utf-8 -*- | |
"""BERT Word Embeddings v2.ipynb | |
Automatically generated by Colaboratory. | |
Original file is located at |
This file contains hidden or 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
""" | |
Basic example showing how to read and validate data from a file using Pydantic. | |
""" | |
import json | |
from typing import List, Optional | |
import pydantic | |
This file contains hidden or 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
import random | |
import string | |
from dataclasses import dataclass, field | |
def generate_id() -> str: | |
return "".join(random.choices(string.ascii_uppercase, k=12)) | |
""" |
This file contains hidden or 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
repos: | |
- repo: https://github.com/pre-commit/pre-commit-hooks | |
rev: v5.0.0 | |
hooks: | |
- id: trailing-whitespace | |
- id: end-of-file-fixer | |
- id: check-yaml | |
- id: debug-statements | |
- id: name-tests-test | |
- id: requirements-txt-fixer |
This file contains hidden or 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
# standard steps to follow for finetunning BERT | |
# 1. Load the pre-trained model | |
# 2. Tokenize the input | |
# 3. Convert the tokens to their index numbers in the BERT vocabulary | |
# 4. Set all of the model’s parameters to their gradients to zero | |
# 5. Run the forward pass, calculate the loss, and perform a backward pass to calculate the gradients | |
# 6. Clip the the gradients to 1.0. It helps in preventing the exploding gradient problem | |
# 7. Update the model’s parameters | |
# 8. Update the learning rate. | |
# 9. Clear the calculated gradients |
This file contains hidden or 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
# standard pre-processing steps for text processing | |
# 1. lower case | |
# 2. remove punctuation | |
# 3. remove stop words | |
# 4. remove numbers | |
# 5. remove short words | |
# 6. lemmatize | |
# 7. stem | |
# 8. remove non-ascii characters | |
# 9. remove extra spaces |
NewerOlder