Skip to content

Instantly share code, notes, and snippets.

View prasadwrites's full-sized avatar

Prasad prasadwrites

View GitHub Profile
# python3 program for spiral matrix
def spiralOrder(matrix):
ans = []
if (len(matrix) == 0):
return ans
m = len(matrix)
@prasadwrites
prasadwrites / lab_3_fine_tune_model_to_detoxify_summaries.ipynb
Created July 7, 2023 17:38
Lab_3_fine_tune_model_to_detoxify_summaries.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@prasadwrites
prasadwrites / lab_2_fine_tune_generative_ai_model.ipynb
Last active July 29, 2023 10:06
Lab_2_fine_tune_generative_ai_model.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/python
def heapify(arr, n, i):
largest = i # Initialize largest as root
l = 2 * i + 1 # left = 2*i + 1
r = 2 * i + 2 # right = 2*i + 2
# See if left child of root exists and is
# greater than root
def maxProfit(arr):
max_profit = 0
diff = 0
mlen = len(arr)
for i in range(mlen):
for j in range( i+1 ,mlen):
if arr[i] < arr[j]:
diff = arr[j] - arr[i]
if max_profit < diff:
@prasadwrites
prasadwrites / lab_1_summarize_dialogue.ipynb
Created July 1, 2023 01:27
Lab_1_summarize_dialogue.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def merge(arr, start , end):
if (start >= end):
return
mid = (end+start)//2
merge(arr, start, mid)
merge(arr, mid+1, end)
left = start
right = mid+1
aux = []
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as tf_text
import tensorflow_datasets as tfds
from official.nlp.data import classifier_data_lib
from official.nlp.bert import tokenization
from official.nlp import optimization
import matplotlib
matplotlib.use('module://matplotlib-backend-kitty')
from transformers import BertForQuestionAnswering, AutoTokenizer
modelname = 'deepset/bert-base-cased-squad2'
model = BertForQuestionAnswering.from_pretrained(modelname)
tokenizer = AutoTokenizer.from_pretrained(modelname)
from transformers import pipeline
nlp = pipeline('question-answering', model=model, tokenizer=tokenizer)
arr=[5,4,8, 10,-4]
k=6
def check_if_sum_possible(arr, k):
slate = []
index = 0
arrlen = 0
if arr:
arrlen = len(arr)