Giter VIP home page Giter VIP logo

Comments (6)

whwang299 avatar whwang299 commented on July 25, 2024

Hi @alekdev2019

Please refer to the issue #4 .

Thanks!

from sqlova.

alekdev2019 avatar alekdev2019 commented on July 25, 2024

Thank you for your quick solution.
I am interesting in changing your code with some different method.
For now, you've been using PyTorch to build the network, but I would like to change it with Tensorflow based.
Would you let me know what is the quick way to achieve this purpose?
Thank you

from sqlova.

whwang299 avatar whwang299 commented on July 25, 2024

Maybe you can start from original BERT code?
Also, as far as I know, most of "natural language → SQL" models are written in pytorch except fews like MAPO (but this is about weak-supervision model) and some baseline code for other SQL training set.

Sorry I can't be of more help on this issue.

Wonseok

from sqlova.

alekdev2019 avatar alekdev2019 commented on July 25, 2024

Thank you for your help.

from sqlova.

alekdev2019 avatar alekdev2019 commented on July 25, 2024

I have an update on this spec.
I am willing to use Keras, and Keras include a lot of similar module with PyTorch.
I am very concerned how I need to convert a class based code(PyTorch)
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss

class BERTEmbeddings(nn.Module):
def init(self, config):
super(BERTEmbeddings, self).init()
"""Construct the embedding module from word, position and token_type embeddings.
"""
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size)
self.position_embeddings = nn.Embedding(config.max_position_embeddings, config.hidden_size)
self.token_type_embeddings = nn.Embedding(config.type_vocab_size, config.hidden_size)

    # self.LayerNorm is not snake-cased to stick with TensorFlow model variable name and be able to load
    # any TensorFlow checkpoint file
    self.LayerNorm = BERTLayerNorm(config)
    self.dropout = nn.Dropout(config.hidden_dropout_prob)

def forward(self, input_ids, token_type_ids=None):
    seq_length = input_ids.size(1)
    position_ids = torch.arange(seq_length, dtype=torch.long, device=input_ids.device)
    position_ids = position_ids.unsqueeze(0).expand_as(input_ids)
    if token_type_ids is None:
        token_type_ids = torch.zeros_like(input_ids)

    words_embeddings = self.word_embeddings(input_ids)
    position_embeddings = self.position_embeddings(position_ids)
    token_type_embeddings = self.token_type_embeddings(token_type_ids)

    embeddings = words_embeddings + position_embeddings + token_type_embeddings
    embeddings = self.LayerNorm(embeddings)
    embeddings = self.dropout(embeddings)
    return embeddings

As you can see, BERTEmbeddings is a class based on torch.nn.Module, but how I can convert it with keras??
Please help me to implement this.
Thank you

from sqlova.

anshudaur avatar anshudaur commented on July 25, 2024

@whwang299 HI , I am also implementing sqlova in keras with bert embeddings.
I am using pytorch trained bert tokenizer to generate words, positions and segment embeddings .
Were you successful in implementing column attention implementation, as i still struggling with it.
Thanks
Anshu

from sqlova.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.