You are on page 1of 23

Technical Career Education Private Limited

5th floor, Sahyadri Campus, Adyar, Mangalore 575007

Innoventure Internship
PROJECT REPORT
2022 – 23

Project Title: ‘AI in education’


Submitted by:
Shwetha K S 4SF21IS101
Aditya Ravi 4SF21CI005
Zeliq Zayyan 4SF21CI059
Hemalatha H S 4SF21CS057
Jampala Poojitha 4SF21CS062
Yagnik S Ram 4SF21CI057

Institution:

Sahyadri College of Engineering and Management


Adyar Mangalore 575007
CONTENTS
Project Overview

1. Introduction

2. Problem Statement

3. Solution
3.1 System requirements for the project.
3.2 Flowchart of the project.
3.3 Frontend
3.4 Backend

4. Conclusion/Outcome:

5. Reference List

1 | skill lab course name


Project Overview

Problem The aim of the project is to leverage AI in education, specifically utilizing


Statement
ChatGPT as an AI tool.

Solution https://drive.google.com/drive/folders/1A6Mlp_fpIcz_izcANJCNeMWyeXkBv
Proposed
2Bw?usp=drive_link
(video Link)
Link to the https://drive.google.com/drive/folders/1sfya5nXdjfHyIEjK3S_8r2cb2FEWk80
final challenge X?usp=drive_link
presentation

Link to photos/ https://drive.google.com/drive/folders/1A6Mlp_fpIcz


videos drive

Github Link https://github.com/dezuivere/edu-AI

Team Name Team 3

Team Members Name USN Class/ College Internship Report


Sectio n (Reference format- Link

Jampala Poojitha 4SF21CS062 CSEA https://www.overleaf.com/read


/ykgdczvwdywp#4c9375
Hemalatha H S 4SF21CS057 CSEB https://www.overleaf.com/read
/zkgcgmhzxjfh#abb231
Shwetha K S 4SF21IS101 ISE A https://www.overleaf.com/proj
ect/6548713321d08db4a35d34
d6
Aditya Ravi 4SF21CI005 AIML https://www.overleaf.com/read
/fmgbwmqwmxcy#0d7f86
Zeliq Zayyan 4SF21CI059 AIML https://www.overleaf.com/read
/zkqfmsqkdfhr#a8db8a
Yagnik S Ram 4SF21CI057 AIML https://www.overleaf.com/read
/rqpbjsdytwnw#599bfe

1. Introduction

2 | skill lab course name


The aim of this project is to leverage AI in education, specifically utilizing ChatGPT as an AI
tool, to address the following challenges:

1. Personalized Learning: Develop an AI system that tailors lessons and learning strategies
according to individual students' needs, taking into account their capabilities and
knowledge gaps. The system should provide personalized learning recommendations to
enhance the efficiency of each student's learning process and bridge gaps in their
understanding.
2. Automation of Administrative Tasks: Implement AI algorithms to automate repetitive
administrative tasks, such as grading, continuous assessment, assignment checking, and
responding to queries. By unburdening teachers from these manual tasks, they can gain a
comprehensive view of students' performance and dedicate more time to high-skilled
responsibilities.
3. Increased Accessibility: Utilize AI to facilitate remote learning, allowing students to
access educational platforms and lessons anytime, anywhere. By eliminating
geographical barriers, AI-enabled education enhances accessibility and enables students
with special needs or learning disabilities to benefit from personalized learning
experiences.
4. Smart Learning Content: Develop a digitized curriculum powered by AI that delivers
interactive, engaging, and simplified learning materials. The system should generate
visualizations, simulations, audios, videos, e-books, and visualized charts, while keeping
the content updated and customized to cater to different learning curves.
5. Virtual Assistants: Integrate virtual assistants, such as AI-powered chatbots, into the
learning system to provide real-time communication and support to students. These
virtual assistants should offer personalized outreach, insightful feedback on curricula, and
assist multiple students simultaneously.

3 | skill lab course name


1. Problem Statement

This project aims to leverage ChatGPT and AI in education to address key challenges:
personalizing learning, automating administrative tasks, increasing accessibility, creating
smart learning content, and integrating virtual assistants to enhance the quality and efficiency
of education.

2. Solution

Our solution involves the development of a responsive chatbot for real-time communication
in the field of education. This chatbot will be designed to facilitate effective and dynamic
interactions between students, teachers, and educational resources, ultimately enhancing the
learning experience.

3.1 System requirements for the project

The system requirements for a chatbot can vary depending on the complexity of its
functionality and the specific use case. However, here are some common system
requirements for developing a chatbot:

Software Requirements:
Programming language: Choose a programming language suitable for developing the
chatbot (e.g., Python, Java, Node.js).
Frameworks and libraries: Utilize appropriate AI and NLP libraries or frameworks (e.g.,
TensorFlow, PyTorch, NLTK, spaCy).
Database: Set up a database to store and retrieve user data or conversation history if
needed.
Operating system: Ensure compatibility with the desired OS (Linux, Windows, etc.).
Natural Language Processing (NLP) Components:

NLP engine: Integrate an NLP engine for understanding and generating human-like
responses.

4 | skill lab course name


Named Entity Recognition (NER): Implement NER for extracting entities from user
input.

User Interface (UI) Requirements:

Web or mobile interface: Develop a user-friendly front-end interface for users to interact
with the chatbot.
Integration with messaging platforms: If applicable, integrate the chatbot with messaging
platforms like Facebook Messenger, Slack, or WhatsApp.
Security Requirements:

Data encryption: Implement secure data transmission and storage to protect user
information.
Authentication and authorization: Establish user authentication and authorization
protocols to ensure data security.
Regular updates and security patches: Keep the chatbot software up to date to address
security vulnerabilities.
Scalability:

Design the chatbot system to be scalable, capable of handling a growing number of users
and interactions.
Integration:

Integration with educational platforms: If used in an educational context, ensure


integration with existing educational tools and platforms.

Testing and Quality Assurance:


Implement a testing strategy to ensure the chatbot functions as intended and provides
accurate responses.
Continuous monitoring and maintenance: Regularly update and maintain the chatbot to
fix issues, improve performance, and add new features.

5 | skill lab course name


Documentation:

Provide comprehensive documentation for users and developers to understand how to use
and extend the chatbot's capabilities.
These are general requirements, and the specific needs of your chatbot project may vary.
It's crucial to conduct a detailed analysis of your project's objectives and constraints to
determine the precise system requirements.

3.3 Overview

EduAI

EduAI is an intelligent Python chatbot designed to assist users in learning about various
programming languages. By simply inputting the name of a language, users can access a
wealth of information and resources. What sets EduAI apart is its text-to-speech feature,
enhancing the accessibility of the tool for visually impaired or differently-abled
individuals. This feature ensures that learning programming languages is an inclusive
experience, opening up opportunities for all. EduAI is not just a chatbot, but a step
towards making programming knowledge universally accessible.

Features
 Provides information on a wide range of programming languages.
 Offers intelligent, language-specific responses, enabling users to get precise
information tailored to their chosen language.
 Features an easy-to-use input interface and organized HTML responses for a
seamless user experience.
 Easily expandable to support additional languages.
 Encourages collaboration and customization for further development.
 Incorporates a text-to-speech feature, enhancing accessibility for visually
impaired or differently-abled individuals.

6 | skill lab course name


Installation

Install Dependencies:
Make sure you have Python installed. This chatbot is written in Python.
Install Gradio if you haven't already. You can use pip for this:
bash
pip install gradio
Also u need to install the google.generativeai module and gtts(Google-text-to-speech)
module :
bash
pip install google-generativeai
bash
pip install gtts
Ensure you have the necessary API key or authentication for the Google Generative AI
API.

Set Up API Key:

Replace 'YOUR_API_KEY' in the code with your actual Google Generative AI API key.
Run the Script:
Run the Python script with the chatbot code.
Interact with the Chatbot:
Once the script is running, open a web browser and navigate to the provided local address
(e.g., http://127.0.0.1:7860/).
Enter a Programming Language:
Input the name of a programming language to interact with the chatbot.
Explore Responses:
The chatbot will generate and display responses about the specified programming
language and also an audio file which can be downloaded.

7 | skill lab course name


Environment Variables

To run this project, you will need to add the following environment variables to your .env
file
API_KEY

8 | skill lab course name


3.3 Chatbot Code

import google.generativeai as palm


import re
import gradio as gr
from gtts import gTTS
from dotenv import load_dotenv
import os
load_dotenv()
apiKey = os.getenv("API_KEY")
palm.configure(api_key=apiKey)
models = [m for m in palm.list_models(
) if 'generateText' in m.supported_generation_methods]
model = models[0].name

def genResp(text):
completion = palm.generate_text(
model=model,
prompt=text,
temperature=0,
max_output_tokens=400 # The maximum length of the response
)
# Ensure the result is a string
if isinstance(completion.result, str):
return completion.result
else:
return str(completion.result)

infoQuestions = [

9 | skill lab course name


"About {}: ",
"PreRequisites of {}: ",
"Requirements of {}: ",
"Installations of {} programming language?",
"Advantages of {}: ",
"Applications of {}: ",
"Concepts to learn {}: ",
"Resources to learn {}: ",
]

def chatWithAI(language, question):


known_programming_languages = [
"python", "java", "c++", "javascript", "ruby", "c",
"c#", "php", "swift", "go", "rust",
"typescript", "perl", "dart", "kotlin", "lua",
"scala", "fortran", "cobol", "bash", "r",
"matlab", "vba", "groovy", "haskell", "groovy",
"elixir", "clojure", "objective-c", "pl/sql", "ada",
"sql", "assembly", "lisp", "prolog", "pascal",
"scheme", "tcl", "smalltalk", "forth", "vhdl",
"verilog", "ada", "racket", "fortran", "erlang",
"f#", "powershell", "cobol", "d", "rpg",
"julia", "dart", "labview", "apex", "r"
]

if language:
language = language.lower()

# Check if the input is in the list of known programming languages


if language in known_programming_languages:
# Generate response based on selected question

10 | skill lab course name


res = re.sub(r"\n", "<br>", genResp(question.format(language)))
response = f'<h2>{question.format(language)}</h2><p>{res}</p>'
return response
else:
rs = re.sub(r"\n", "<br>", genResp(f"What is {language}?"))
response = f'The provided input is not a known programming
language.<br><h2>{language}</h2><p>{rs}</p>'
return response
else:
return "Please enter the name of a programming language."

# this function will convert our text response into speech


def text_to_speech(text):
newText = text
stars = ['**', '*']
for star in stars:
newText = newText.replace(star, '')

# Remove HTML tags from the text


icons = ['<br>', '<h2>', '<p>', '</br>', '</h2>', '</p>', '**', '*']
for icon in icons:
text = text.replace(icon, '')

# Convert text to speech


tts = gTTS(text=text, lang='en', slow=False)

# Save the speech audio into a file


filename = "speech.mp3"
# every time when user inputs the input the audio file is overwrittem
tts.save(filename)
return filename, newText

11 | skill lab course name


inputs = [gr.inputs.Textbox(lines=1, label="ProgrammerPal"), gr.inputs.Radio(
infoQuestions, label="What Do You Want to Know?")]
outputs = [gr.outputs.Audio(
type='filepath', label="speech"), gr.outputs.HTML(label="reply")]

# Create a Gradio interface


chatInterface = gr.Interface(
fn=lambda x, y: text_to_speech(chatWithAI(x, y)),
inputs=inputs,
outputs=outputs,
title="Chatbot for Engineers",
description="Enter the name of a programming language.",
theme=gr.themes.Base(),
)

chatInterface.launch()

We added a useful and advanced feature for a chatbot.


Being able to upload a document and have the chatbot extract information from it to
answer user's questions can be valuable in various scenarios.

import os
file_uploaded_state = False
from typing import TypeVar
from langchain.embeddings import HuggingFaceEmbeddings#,
HuggingFaceInstructEmbeddings
from langchain.vectorstores import FAISS
import gradio as gr
from transformers import AutoTokenizer
from ctransformers import AutoModelForCausalLM

12 | skill lab course name


PandasDataFrame = TypeVar('pd.core.frame.DataFrame')
import chatfuncs.ingest as ing

## Load preset embeddings, vectorstore, and model


embeddings_name = "BAAI/bge-base-en-v1.5"

def load_embeddings(embeddings_name = "BAAI/bge-base-en-v1.5"):


embeddings_func = HuggingFaceEmbeddings(model_name=embeddings_name)
global embeddings
embeddings = embeddings_func
return embeddings

def get_faiss_store(faiss_vstore_folder,embeddings):
import zipfile
with zipfile.ZipFile(faiss_vstore_folder + '/' + faiss_vstore_folder + '.zip', 'r') as
zip_ref:
zip_ref.extractall(faiss_vstore_folder)
faiss_vstore = FAISS.load_local(folder_path=faiss_vstore_folder,
embeddings=embeddings)
os.remove(faiss_vstore_folder + "/index.faiss")
os.remove(faiss_vstore_folder + "/index.pkl")
global vectorstore
vectorstore = faiss_vstore
return vectorstore
import chatfuncs.chatfuncs as chatf

chatf.embeddings = load_embeddings(embeddings_name)
chatf.vectorstore =
get_faiss_store(faiss_vstore_folder="faiss_embedding",embeddings=globals()
["embeddings"])

13 | skill lab course name


def load_model(model_type, gpu_layers, gpu_config=None, cpu_config=None,
torch_device=None):
print("Loading model")

# Default values inside the function


if cpu_config is None:
cpu_config = chatf.cpu_config

hf_checkpoint = 'declare-lab/flan-alpaca-large'#'declare-lab/flan-alpaca-base' # # #

def create_hf_model(model_name):

from transformers import AutoModelForSeq2SeqLM, AutoModelForCausalLM


model = AutoModelForSeq2SeqLM.from_pretrained(model_name)

tokenizer = AutoTokenizer.from_pretrained(model_name, model_max_length =


chatf.context_length)
return model, tokenizer, model_type

model, tokenizer, model_type = create_hf_model(model_name = hf_checkpoint)


chatf.model = model
chatf.tokenizer = tokenizer
chatf.model_type = model_type
load_confirmation = "Finished loading model: " + model_type
print(load_confirmation)
return model_type, load_confirmation, model_type

model_type = "Flan Alpaca (small, fast)"


load_model(model_type, 0, chatf.cpu_config)

def docs_to_faiss_save(docs_out:PandasDataFrame, embeddings=embeddings):

14 | skill lab course name


print(f"> Total split documents: {len(docs_out)}")
print(docs_out)
vectorstore_func = FAISS.from_documents(documents=docs_out,
embedding=embeddings)
chatf.vectorstore = vectorstore_func
out_message = "Document processing complete"
return out_message, vectorstore_func
# Gradio chat
block = gr.Blocks(theme = gr.themes.Soft())

with block:
ingest_text = gr.State()
ingest_metadata = gr.State()
ingest_docs = gr.State()

model_type_state = gr.State(model_type)
embeddings_state = gr.State(globals()["embeddings"])
vectorstore_state = gr.State(globals()["vectorstore"])

model_state = gr.State() # chatf.model (gives error)


tokenizer_state = gr.State() # chatf.tokenizer (gives error)

chat_history_state = gr.State()
instruction_prompt_out = gr.State()

gr.Markdown("<h1><center>TextBook AI</center></h1>")

gr.Markdown("Chat with textbook documents. This is a small model (Flan Alpaca),


that can only answer specific questions that are answered in the text. It cannot give
overall impressions of, or summarise the document.\n\n Please note that LLM chatbot

15 | skill lab course name


may give incomplete or incorrect information, so please use with care.")

with gr.Row():
current_source = gr.Textbox(label="Current data source(s)", value="Lambeth_2030-
Our_Future_Our_Lambeth.pdf", scale = 10,visible=False)
current_model = gr.Textbox(label="Current model", value=model_type, scale =
3,visible=False)

with gr.Tab("Chatbot"):

with gr.Row():
#chat_height = 500
chatbot = gr.Chatbot(avatar_images=('user.gif', 'bot_icon.gif'),bubble_full_width
= False, scale = 1) # , height=chat_height
with gr.Accordion("Open this tab to see the source paragraphs used to generate
the answer", open = False):
sources = gr.HTML(value = "Source paragraphs with the most relevant text
will appear here", scale = 1) # , height=chat_height

with gr.Row():
message = gr.Textbox(
label="Enter your question here",
lines=1,
)
with gr.Row():
submit = gr.Button(value="Send message", variant="secondary", scale = 1)

current_topic = gr.Textbox(label="Feature currently disabled - Keywords related to


current conversation topic.", placeholder="Keywords related to the conversation topic
will appear here",visible=False)

16 | skill lab course name


with gr.Row():
with gr.Tab("Load in a file to chat with"):
with gr.Accordion("PDF file", open = False):
in_pdf = gr.File(label="Upload pdf", file_count="multiple", file_types=['.pdf'])
load_pdf = gr.Button(value="Load in file", variant="secondary", scale=0)

ingest_embed_out = gr.Textbox(label="File preparation progress")

# with gr.Tab("Advanced features"):


out_passages = gr.Slider(minimum=1, value = 2, maximum=10, step=1,
label="Choose number of passages to retrieve from the document. Numbers greater than
2 may lead to increased hallucinations or input text being truncated.",visible=False)
temp_slide = gr.Slider(minimum=0.1, value = 0.1, maximum=1, step=0.1,
label="Choose temperature setting for response generation.", visible=False)

# Load in a pdf
load_pdf_click = load_pdf.click(ing.parse_file, inputs=[in_pdf], outputs=[ingest_text,
current_source])\
.then(ing.text_to_docs, inputs=[ingest_text], outputs=[ingest_docs])\
.then(docs_to_faiss_save, inputs=[ingest_docs], outputs=[ingest_embed_out,
vectorstore_state])\
.then(chatf.hide_block)
file_uploaded_state= True

if file_uploaded_state:
# Click/enter to send message action
response_click = submit.click(chatf.create_full_prompt, inputs=[message,
chat_history_state, current_topic, vectorstore_state, embeddings_state, model_type_state,
out_passages], outputs=[chat_history_state, sources, instruction_prompt_out],
queue=False, api_name="retrieval").\

17 | skill lab course name


then(chatf.turn_off_interactivity, inputs=[message, chatbot],
outputs=[message, chatbot], queue=False).\
then(chatf.produce_streaming_answer_chatbot, inputs=[chatbot,
instruction_prompt_out, model_type_state], outputs=chatbot)
response_click.then(chatf.add_inputs_answer_to_history,[message, chatbot,
current_topic], [chat_history_state, current_topic]).\
then(lambda: chatf.restore_interactivity(), None, [message], queue=False)
block.queue(concurrency_count=1).launch(debug=True)
#-

18 | skill lab course name


4. Conclusion/Outcome

In conclusion, this internship experience at Novigo Solutions has been a valuable


opportunity for me to gain practical experience in developing Chatbots using API keys.
Working as a team, we've honed our technical skills and recognized the paramount
importance of teamwork in achieving our project's goals.
We consider this internship experience a valuable opportunity for personal and
professional growth, and we eagerly anticipate applying the skills and knowledge
acquired to future projects and endeavors.

By addressing these challenges, the project aims to revolutionize education by leveraging


AI to deliver personalized learning experiences, automate administrative tasks, increase
accessibility, provide smart learning content, and offer virtual assistants to enhance
student engagement and support.

19 | skill lab course name


20 | skill lab course name
21 | skill lab course name
5. References

1. https://www.gradio.app/docs/chatbot
2. https://www.gradio.app/docs/interface
3. https://platform.openai.com/docs/api-reference
4. https://github.com/dezuivere/edu-AI
5. https://www.youtube.com/watch?v=eE7CamOE-PA
6. https://docs.google.com/spreadsheets/d/
1VEUlfg0rc4wKS61QfdDmQoun_QG94hrrAM1il80IrG0/edit#gid=100338575

22 | skill lab course name

You might also like