1. A method comprising: receiving a message in an online system, the message including a hashtag character and a string of characters; determining a set of candidate phrases that each match one or more words identified from a subset of the string of characters; scoring each of the candidate phrases based on frequencies at which the candidate phrases occur in a sample of messages of the online system; selecting a candidate phrase of the set of candidate phrases based on the scoring; and predicting a topic of the message by providing the selected candidate phrase as input to a model configured to predict associations of hashtag phrases with message topics, the model trained using feature vectors including a plurality of hashtag phrases received from users of the online system.