|
import streamlit as st |
|
import base64 |
|
from weasyprint import HTML |
|
import io |
|
|
|
|
|
ml_outline = [ |
|
"π 1. Mixture of Experts (MoE)", |
|
"π₯ 2. Supervised Fine-Tuning (SFT) using PyTorch", |
|
"π€ 3. Large Language Models (LLM) using Transformers", |
|
"π 4. Self-Rewarding Learning using NPS 0-10 and Verbatims", |
|
"π 5. Reinforcement Learning from Human Feedback (RLHF)", |
|
"π 6. MergeKit: Merging Models to Same Embedding Space", |
|
"π 7. DistillKit: Model Size Reduction with Spectrum Analysis", |
|
"π§ 8. Agentic RAG Agents using Document Inputs", |
|
"β³ 9. Longitudinal Data Summarization from Multiple Docs", |
|
"π 10. Knowledge Extraction using Markdown Knowledge Graphs", |
|
"πΊοΈ 11. Knowledge Mapping with Mermaid Diagrams", |
|
"π» 12. ML Code Generation with Streamlit/Gradio/HTML5+JS" |
|
] |
|
|
|
def create_pdf_with_weasyprint(outline_items): |
|
|
|
html_content = """ |
|
<html> |
|
<head> |
|
<style> |
|
body { |
|
font-family: Arial, sans-serif; |
|
margin: 20px; |
|
} |
|
.container { |
|
display: flex; |
|
width: 100%; |
|
height: 500px; |
|
} |
|
.column { |
|
width: 50%; |
|
padding: 10px; |
|
} |
|
h2 { |
|
color: #2c3e50; |
|
} |
|
ul { |
|
list-style-type: none; |
|
padding-left: 0; |
|
} |
|
li { |
|
margin: 8px 0; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="container"> |
|
<div class="column"> |
|
<h2>Cutting-Edge ML Areas (1-6)</h2> |
|
<ul> |
|
""" |
|
|
|
|
|
for item in outline_items[:6]: |
|
html_content += f"<li>{item}</li>" |
|
|
|
html_content += """ |
|
</ul> |
|
</div> |
|
<div class="column"> |
|
<h2>Cutting-Edge ML Areas (7-12)</h2> |
|
<ul> |
|
""" |
|
|
|
|
|
for item in outline_items[6:]: |
|
html_content += f"<li>{item}</li>" |
|
|
|
html_content += """ |
|
</ul> |
|
</div> |
|
</div> |
|
</body> |
|
</html> |
|
""" |
|
|
|
|
|
buffer = io.BytesIO() |
|
HTML(string=html_content).write_pdf(buffer) |
|
pdf_bytes = buffer.getvalue() |
|
buffer.close() |
|
|
|
return pdf_bytes |
|
|
|
def get_binary_file_downloader_html(bin_file, file_label='File'): |
|
bin_str = base64.b64encode(bin_file).decode() |
|
href = f'<a href="data:application/octet-stream;base64,{bin_str}" download="{file_label}">Download {file_label}</a>' |
|
return href |
|
|
|
|
|
st.title("π Cutting-Edge ML Outline Generator") |
|
|
|
col1, col2 = st.columns(2) |
|
|
|
with col1: |
|
st.header("π Markdown Outline") |
|
outline_text = "\n".join(ml_outline) |
|
st.markdown(outline_text) |
|
|
|
md_file = "ml_outline.md" |
|
with open(md_file, "w") as f: |
|
f.write(outline_text) |
|
st.markdown(get_binary_file_downloader_html(md_file.encode(), "ml_outline.md"), unsafe_allow_html=True) |
|
|
|
with col2: |
|
st.header("π PDF Preview") |
|
|
|
if st.button("Generate PDF"): |
|
with st.spinner("Generating PDF..."): |
|
try: |
|
pdf_bytes = create_pdf_with_weasyprint(ml_outline) |
|
|
|
|
|
with open("ml_outline.pdf", "wb") as f: |
|
f.write(pdf_bytes) |
|
|
|
st.download_button( |
|
label="Download PDF", |
|
data=pdf_bytes, |
|
file_name="ml_outline.pdf", |
|
mime="application/pdf" |
|
) |
|
|
|
base64_pdf = base64.b64encode(pdf_bytes).decode('utf-8') |
|
pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="100%" height="400" type="application/pdf"></iframe>' |
|
st.markdown(pdf_display, unsafe_allow_html=True) |
|
except Exception as e: |
|
st.error(f"Error generating PDF: {str(e)}") |
|
|
|
st.markdown(""" |
|
<style> |
|
.stButton>button { |
|
background-color: #4CAF50; |
|
color: white; |
|
} |
|
</style> |
|
""", unsafe_allow_html=True) |