Answers.Body: <p>You could try to train a recurrent neural net on char level. Basically, you took GRU or LSTM and use a sequence of characters, not tags or words. In the blogpost <a href="http://karpathy.github.io/2015/05/21/rnn-effectiveness/" rel="nofollow noreferrer">&quot;The Unreasonable Effectiveness of Recurrent Neural Networks&quot;</a> there are examples for Shakespeare, Linux source code on C and for papers in latex code, and the results are quite valid, produced from similar to your size training sets. The good thing in case of html pages is that modern browsers are very good at handling a slightly broken HTML, so this approach could work for both of your tasks.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-26T11:50:20.160Z
Answers.LastActivityDate: 2021-03-26T11:56:32.903Z
Answers.LastEditDate: 2021-03-26T11:56:32.903Z
Answers.UserDisplayName: Kirill Fedyanin
Body: <p>I don't know anything about ML or NLP, but I was asked by someone to create brand new statutes (written laws) that resemble the ones currently in effect in my country. I have already gathered the laws, and have 5000 html files now, one per law.</p>
  <p>The average size of each html file is 49 kB. The entire corpus is 300 MB.</p>
  <p>I have two alternative goals (doing both would be perfect of course):</p>
  <ul>
  <li><p>Generate a new, complete HTML file, that would imitate the 5000 existing ones (it would typically have 1 big heading at the top, sub-headings, articles with their own title and number, etc.)</p>
  </li>
  <li><p>Generate sentences that sound as if they could be found in a typical law (the laws are written in French)</p>
  </li>
  </ul>
  <p>Is any of those goals feasible, with such a small corpus (~300 MB total)?</p>
  <p>Should I try and fine-tune an existing model (but in that case, wouldn't the small size of my corpus be a problem? Wouldn't it be &quot;drowned out&quot; in the rest of the training data?), or should I create one from scratch?</p>
  <p>I've tried following guides on huggingface, but between the obsolete files, the undocumented flags and my general lack of knowledge of the subject, I'm completely lost.</p>
  <p>Thanks in advance.</p>
  <p>BTW, if you want to take a peek at the data, there it is: <a href="https://github.com/Biganon/rs/" rel="nofollow noreferrer">https://github.com/Biganon/rs/</a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-24T10:59:10.553Z
Comments.Text: "I don't know anything about ML or NLP" --> why should u take the task, btw, text generation is just for fun, won't ever be law (must be exact, precise, no bad logics)
Comments.UserDisplayName: Dan D.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-26T11:26:44.580Z
Comments.Text: @datdinhquoc I took the task because I'm the only teaching assistant in the law faculty who is at least slightly comfortable around computers, and I thought it would be fun. I am not required to fulfill the task, I just thought it would be interesting. Also, we don't want to produce law that will be used, we want to use this as an experiment, precisely to show the limits of the system. I'm still hoping someone can point me in the right direction.
Comments.UserDisplayName: Biganon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-31T02:55:56.460Z
Comments.Text: Why does it need to be in HTML? Why not simply the raw texts of the statutes themselves. HTML formatting introduces extra complexity, and is the same in every file: it does not to be learned.
Comments.UserDisplayName: Vladislav Gladkikh
Tags: <natural-language-processing><natural-language-generation>
Title: I have 5000 html files (structured text), how can I generate a new one that "resembles" those?
UserDisplayName: Biganon
ThreadText: # I have 5000 html files (structured text), how can I generate a new one that "resembles" those?
  
  (Asked by: username_0 on 2021-03-23)
  
  I don't know anything about ML or NLP, but I was asked by someone to create brand new statutes (written laws) that resemble the ones currently in effect in my country. I have already gathered the laws, and have 5000 html files now, one per law.
  
  The average size of each html file is 49 kB. The entire corpus is 300 MB.
  
  I have two alternative goals (doing both would be perfect of course):
  
  * Generate a new, complete HTML file, that would imitate the 5000 existing ones (it would typically have 1 big heading at the top, sub-headings, articles with their own title and number, etc.)
  * Generate sentences that sound as if they could be found in a typical law (the laws are written in French)
  
  Is any of those goals feasible, with such a small corpus (~300 MB total)?
  
  Should I try and fine-tune an existing model (but in that case, wouldn't the small size of my corpus be a problem? Wouldn't it be "drowned out" in the rest of the training data?), or should I create one from scratch?
  
  I've tried following guides on huggingface, but between the obsolete files, the undocumented flags and my general lack of knowledge of the subject, I'm completely lost.
  
  Thanks in advance.
  
  BTW, if you want to take a peek at the data, there it is: <https://github.com/username_0/rs/>
  
  **Tags:** natural-language-processing, natural-language-generation
  
  > **Comments:**
  > **username_1**: "I don't know anything about ML or NLP" --> why should u take the task, btw, text generation is just for fun, won't ever be law (must be exact, precise, no bad logics)  
  > **username_0**: @datdinhquoc I took the task because I'm the only teaching assistant in the law faculty who is at least slightly comfortable around computers, and I thought it would be fun. I am not required to fulfill the task, I just thought it would be interesting. Also, we don't want to produce law that will be used, we want to use this as an experiment, precisely to show the limits of the system. I'm still hoping someone can point me in the right direction.  
  > **username_2**: Why does it need to be in HTML? Why not simply the raw texts of the statutes themselves. HTML formatting introduces extra complexity, and is the same in every file: it does not to be learned.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2021-03-26. Score: 1
  
  You could try to train a recurrent neural net on char level. Basically, you took GRU or LSTM and use a sequence of characters, not tags or words. In the blogpost ["The Unreasonable Effectiveness of Recurrent Neural Networks"](http://karpathy.github.io/2015/05/21/rnn-effectiveness/) there are examples for Shakespeare, Linux source code on C and for papers in latex code, and the results are quite valid, produced from similar to your size training sets. The good thing in case of html pages is that modern browsers are very good at handling a slightly broken HTML, so this approach could work for both of your tasks.
  
  
  ---
  
  