Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""llama_cpp_quiz_generator.ipynb
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colab.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1V287A0U9MlfTEEPjBPDsREKdNMbxwg9V
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
!pip install langchain
|
| 11 |
+
!pip install llama-cpp-python
|
| 12 |
+
!pip install langchain_community
|
| 13 |
+
|
| 14 |
+
# Mount the Google Drive folder to Colab
|
| 15 |
+
from google.colab import drive
|
| 16 |
+
drive.mount('/content/drive')
|
| 17 |
+
|
| 18 |
+
from langchain.prompts import ChatPromptTemplate
|
| 19 |
+
from langchain.chains import LLMChain
|
| 20 |
+
from langchain_community.llms import LlamaCpp
|
| 21 |
+
|
| 22 |
+
llm = LlamaCpp(
|
| 23 |
+
model_path="/content/drive/My Drive/LLM/models/Meta-Llama-3.1-8B-Instruct-Q5_K_M.gguf",
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
prompt = ChatPromptTemplate.from_template(
|
| 27 |
+
"Generate 2 questions and their correct answers based on the following text:\n\n{text}\n\n"
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
chain = LLMChain(llm=llm, prompt=prompt)
|
| 31 |
+
|
| 32 |
+
text = "In general, IFC, or “Industry Foundation Classes”, \
|
| 33 |
+
is a standardized, digital description of the built environment, \
|
| 34 |
+
including buildings and civil infrastructure. \
|
| 35 |
+
It is an open, international standard (ISO 16739-1:2018), \
|
| 36 |
+
meant to be vendor-neutral, or agnostic, and usable across a wide range of hardware devices, \
|
| 37 |
+
software platforms, and interfaces for many different use cases. \
|
| 38 |
+
The IFC schema specification is the primary technical deliverable of buildingSMART International to fulfill its goal to promote openBIM."
|
| 39 |
+
|
| 40 |
+
quiz = chain.invoke(text)
|
| 41 |
+
print(quiz['text'])
|