Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not an issue - just some research in turning pdf -> code #14

Open
johndpope opened this issue Aug 3, 2023 · 0 comments
Open

not an issue - just some research in turning pdf -> code #14

johndpope opened this issue Aug 3, 2023 · 0 comments

Comments

@johndpope
Copy link

johndpope commented Aug 3, 2023

I've been playing around and came across this today
it's possible this repo could take things one step further.
can you can train chat models with your own data - using pinecone -
it would probably be possible to have similar results to below without too much effort but with sympytorch.

https://pdf2gpt.com/

https://arxiv.org/pdf/2307.16171.pdf

ask question
can you provide latex equations from doc?

Pages 1—2: Equations, Latex, summarization
Here are some latex equations from the document:


Equation (1):
$\[
\log p_{\theta}(x|c) \geq \mathbb{E}_{q_{\phi}(z|x)} \left[ \log p_{\theta_d}(x|z_a) - \log q_{\phi_a}(z_a|x_{\text{spec}}) + \log p_{\theta_a}(z_a|z_l) - \log q_{\phi_l}(z_l|x_{w2v}) \right]
\]$

Equation (2):
$\[
L_{\text{pitch}} = \|\log p_x - G_s(z_a, s)\|_1
\]$

Equation (3):
$\[
L_{\text{STFT}} = \|\psi(x) - \psi(G_w(z_a, p_h, s))\|_1
\]$

Equation (4):
$\[
L_{\text{adv}}(D) = \mathbb{E}_{x,z_a} \left[ (D(x)-1)^2 + D(G(z_a, s))^2 \right]
\]$

Equation (5):
$\[
L_{\text{adv}}(\phi_a, \theta_d) = \mathbb{E}_{z_a} \left[ (D(G(z_a, s))-1)^2 \right]
\]$

chatgpt
can you provide some sympy code for following equations - with some dummy data - Equation (1):

Sure, I can provide SymPy code for each of the equations with some dummy data. Note that SymPy is mainly used for symbolic mathematics, so we'll be creating symbolic representations of the equations rather than solving them numerically.

Before we start, let's define the symbols used in the equations:

  • x: Data variable.
  • c: Some context.
  • p_theta, p_theta_d, p_theta_a: Probability distributions with parameters theta, theta_d, and theta_a, respectively.
  • q_phi, q_phi_a, q_phi_l: Probability distributions with parameters phi, phi_a, and phi_l, respectively.
  • z: Latent variable.
  • z_a: Latent variable related to the attribute a.
  • z_l: Latent variable related to the label l.
  • x_spec, x_w2v: Some specific data or context for x and w2v (word2vec) models, respectively.
  • L_pitch, L_STFT, L_adv: Different loss terms.
  • G_s, G_w: Functions that take some inputs and generate data.

Now let's define the equations in SymPy:

import sympy as sp

# Define symbols
x, c, z, z_a, z_l, x_spec, x_w2v, p_theta, p_theta_d, p_theta_a = sp.symbols('x c z z_a z_l x_spec x_w2v p_theta p_theta_d p_theta_a')
q_phi, q_phi_a, q_phi_l = sp.symbols('q_phi q_phi_a q_phi_l')
s, p_h = sp.symbols('s p_h')
D = sp.symbols('D', cls=sp.Function)

# Equation (1)
eq1 = sp.log(p_theta(x|c)) >= sp.E**sp.integrate(sp.log(p_theta_d(x|z_a)) - sp.log(q_phi_a(z_a|x_spec)) + sp.log(p_theta_a(z_a|z_l)) - sp.log(q_phi_l(z_l|x_w2v)), (z, q_phi(z|x)))

# Equation (2)
G_s = sp.Function('G_s')
L_pitch = sp.norm(sp.log(x) - G_s(z_a, s), 1)

# Equation (3)
G_w = sp.Function('G_w')
psi = sp.Function('psi')
L_STFT = sp.norm(psi(x) - psi(G_w(z_a, p_h, s)), 1)

# Equation (4)
L_adv_D = sp.E**sp.integrate((D(x) - 1)**2 + D(G(z_a, s))**2, (x, z_a))

# Equation (5)
L_adv_phi_theta = sp.E**sp.integrate((D(G(z_a, s)) - 1)**2, (z_a, q_phi_a(z_a|x_spec)))

# Print equations
print("Equation (1):")
sp.pprint(eq1)

print("\nEquation (2):")
sp.pprint(L_pitch)

print("\nEquation (3):")
sp.pprint(L_STFT)

print("\nEquation (4):")
sp.pprint(L_adv_D)

print("\nEquation (5):")
sp.pprint(L_adv_phi_theta)

Please note that these equations will not be solvable in the usual sense due to the presence of integrals and probability distributions with unknown functional forms. But the above code will help you create symbolic representations of the equations for further manipulations or analyses in SymPy.

I did another one with physics -- you can prompt gpt to dream up applicability / dummy values. here I gave it direct equation - and ask it to explain it in children terms.
https://gist.github.com/johndpope/ab1f334b615222b81505b6a26e5e3fbd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant