Welcome, Guest

Author Topic: Coding  (Read 97338 times)

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Coding
« Reply #690 on: January 19, 2018, 07:53:44 PM »
in each of these images, one row was generated by a neural network and the other one is human generated

Jorster

  • ****
  • Posts: 37
  • karma chameleon
Re: Coding
« Reply #691 on: January 21, 2018, 09:47:56 PM »
I made a Darvince IRC Markov chain bot
Code: [Select]
import json
import markovify
import socket
import random
import time
       
server = "irc.freenode.net" # Server
channel = "##universesandbox" # Channel
botnick = "BotVince" # Your bots nick
print("Opening Brainfile")
corpus = open("darvincelines.txt").read()
print("Converting Brainfile to json")
text_model = markovify.Text(corpus, state_size=3)
model_json = text_model.to_json()
print("Success")
reconstituted_model = markovify.Text.from_json(model_json)

def ping(): # Respond to server pings
  ircsock.send("PONG :pingis\n")

def joinchan(chan): # Join a channel
  ircsock.send("JOIN "+ chan +"\n")

ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ircsock.connect((server, 6667)) # Here we connect to the server using the port 6667
ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :Jister - A bot made by Jorster on USF\n") # user authentication
ircsock.send("NICK "+ botnick +"\n") # here we actually assign the nick to the bot

joinchan(channel) # Join the channel using the functions we previously defined

while 1: # Be careful with these! it might send you to an infinite loop
ircmsg = ircsock.recv(2048) # receive data from the server
ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
ircmsg = ircmsg.lower() # Converting to lowercase for easier finding of kol
print(ircmsg) # Here we print what's coming from the server
if ircmsg.find("ping :") != -1: # If the server pings us then we've got to respond!
ping()
if ircmsg.find("##universesandbox") != -1: # Make sure we're getting a message from the irc channel
if ircmsg.find("darvince") != -1:
if random.randint(1,10) == 1:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
markov = "markov failed yell at jorster"
ircsock.send("PRIVMSG " + channel + " :" + markov + "\n")
if ircmsg.find("!dar") != -1:
print("!dar found")
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
markov = "markov failed yell at jorster"
print(markov)
ircsock.send("PRIVMSG " + channel + " :" + markov + "\n")
It was a fun experiment in markov chains and irc bots

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Coding
« Reply #692 on: January 22, 2018, 06:19:04 PM »
some thoughts on a next gen irc bot

gen 0: old old ubv, using some weird-ass bespoke key word search i made up. could repeat previously said text. actually was quite coherent

gen 1: trigram model (old ubv and current jister). attention span of 2 words max.

gen 2: standard lstm model with single line attention span. would also expect much lower perplexity than trigrams

gen 3: both a line and paragraph lstm model, where the paragraph level lstm model produces some context vector which is fed in to the line lstm. this would allow bot to have a long attention span

gen 4: gen 3 + pointer networks attention mechanism, which would be very useful for irc, due to the limited amount of training data.

gen 5: gen 4 + gan loss, cause why not.

references
thought vectors: https://arxiv.org/abs/1506.06726
pointer networks: https://arxiv.org/abs/1506.03134
seqgan: https://arxiv.org/abs/1609.05473
« Last Edit: January 22, 2018, 06:25:11 PM by vh »